wip
This commit is contained in:
parent
efaaf0a4dc
commit
269d56a07b
|
@ -16,4 +16,6 @@ enum SharingAction: Stateable {
|
||||||
case galleryItemsUpdated(items: [SharingGalleryItem])
|
case galleryItemsUpdated(items: [SharingGalleryItem])
|
||||||
|
|
||||||
case cameraCaptured(media: Data, type: SharingCameraMediaType)
|
case cameraCaptured(media: Data, type: SharingCameraMediaType)
|
||||||
|
|
||||||
|
case retrySharing(messageId: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,6 +395,29 @@ final class DatabaseMiddleware {
|
||||||
}
|
}
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
|
|
||||||
|
case .sharingAction(.retrySharing(let id)):
|
||||||
|
return Future<AppAction, Never> { promise in
|
||||||
|
Task(priority: .background) { [weak self] in
|
||||||
|
guard let database = self?.database else {
|
||||||
|
promise(.success(.databaseAction(.storeMessageFailed(reason: L10n.Global.Error.genericDbError)))
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
_ = try database._db.write { db in
|
||||||
|
try Message
|
||||||
|
.filter(Column("id") == id)
|
||||||
|
.updateAll(db, Column("pending").set(to: true), Column("sentError").set(to: false))
|
||||||
|
}
|
||||||
|
promise(.success(.empty))
|
||||||
|
} catch {
|
||||||
|
promise(.success(.databaseAction(.storeMessageFailed(reason: error.localizedDescription)))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.eraseToAnyPublisher()
|
||||||
|
|
||||||
case .xmppAction(.xmppAttachmentUploadSuccess(let messageId, let remotePath)):
|
case .xmppAction(.xmppAttachmentUploadSuccess(let messageId, let remotePath)):
|
||||||
return Future<AppAction, Never> { promise in
|
return Future<AppAction, Never> { promise in
|
||||||
Task(priority: .background) { [weak self] in
|
Task(priority: .background) { [weak self] in
|
||||||
|
@ -407,7 +430,7 @@ final class DatabaseMiddleware {
|
||||||
_ = try database._db.write { db in
|
_ = try database._db.write { db in
|
||||||
try Message
|
try Message
|
||||||
.filter(Column("id") == messageId)
|
.filter(Column("id") == messageId)
|
||||||
.updateAll(db, Column("attachmentRemotePath").set(to: remotePath), Column("pending").set(to: false))
|
.updateAll(db, Column("attachmentRemotePath").set(to: remotePath), Column("pending").set(to: false), Column("sentError").set(to: false))
|
||||||
}
|
}
|
||||||
promise(.success(.empty))
|
promise(.success(.empty))
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -70,7 +70,7 @@ private struct AttachmentView: View {
|
||||||
let message: Message
|
let message: Message
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if message.attachmentDownloadFailed {
|
if message.attachmentDownloadFailed || (message.attachmentLocalName != nil && message.sentError) {
|
||||||
failed
|
failed
|
||||||
} else {
|
} else {
|
||||||
switch message.attachmentType {
|
switch message.attachmentType {
|
||||||
|
@ -134,6 +134,8 @@ private struct AttachmentView: View {
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if let url = message.attachmentRemotePath {
|
if let url = message.attachmentRemotePath {
|
||||||
store.dispatch(.fileAction(.downloadAttachmentFile(messageId: message.id, attachmentRemotePath: url)))
|
store.dispatch(.fileAction(.downloadAttachmentFile(messageId: message.id, attachmentRemotePath: url)))
|
||||||
|
} else if message.attachmentLocalName != nil && message.sentError {
|
||||||
|
store.dispatch(.sharingAction(.retrySharing(messageId: message.id)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue