fix: MessageSendJob.kt sets message as sending before calling send so conversation adapter doesn't display as error / let users retry while send job is pending

pull/624/head
jubb 3 years ago
parent 7459765a52
commit ab876ca9b8

@ -1182,11 +1182,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
}
message.addSignalAttachments(mmsMessageRecord.slideDeck.asAttachments())
}
val sentTimestamp = message.sentTimestamp
val sender = MessagingModuleConfiguration.shared.storage.getUserPublicKey()
if (sentTimestamp != null && sender != null) {
MessagingModuleConfiguration.shared.storage.markAsSending(sentTimestamp, sender)
}
MessageSender.send(message, recipient.address)
}
endActionMode()

@ -36,6 +36,7 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
override fun execute() {
val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider
val message = message as? VisibleMessage
val storage = MessagingModuleConfiguration.shared.storage
if (message != null) {
if (!messageDataProvider.isOutgoingMessage(message.sentTimestamp!!)) return // The message has been deleted
val attachmentIDs = mutableListOf<Long>()
@ -45,7 +46,7 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
val attachments = attachmentIDs.mapNotNull { messageDataProvider.getDatabaseAttachment(it) }
val attachmentsToUpload = attachments.filter { it.url.isNullOrEmpty() }
attachmentsToUpload.forEach {
if (MessagingModuleConfiguration.shared.storage.getAttachmentUploadJob(it.attachmentId.rowId) != null) {
if (storage.getAttachmentUploadJob(it.attachmentId.rowId) != null) {
// Wait for it to finish
} else {
val job = AttachmentUploadJob(it.attachmentId.rowId, message.threadID!!.toString(), message, id!!)
@ -57,6 +58,11 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
return
} // Wait for all attachments to upload before continuing
}
val sentTimestamp = this.message.sentTimestamp
val sender = storage.getUserPublicKey()
if (sentTimestamp != null && sender != null) {
storage.markAsSending(sentTimestamp, sender)
}
val promise = MessageSender.send(this.message, this.destination).success {
this.handleSuccess()
}.fail { exception ->

Loading…
Cancel
Save