mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-21 10:38:26 +00:00
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
This commit is contained in:
parent
7459765a52
commit
ab876ca9b8
@ -1182,11 +1182,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
message.addSignalAttachments(mmsMessageRecord.slideDeck.asAttachments())
|
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)
|
MessageSender.send(message, recipient.address)
|
||||||
}
|
}
|
||||||
endActionMode()
|
endActionMode()
|
||||||
|
@ -36,6 +36,7 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
|
|||||||
override fun execute() {
|
override fun execute() {
|
||||||
val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider
|
val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider
|
||||||
val message = message as? VisibleMessage
|
val message = message as? VisibleMessage
|
||||||
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (!messageDataProvider.isOutgoingMessage(message.sentTimestamp!!)) return // The message has been deleted
|
if (!messageDataProvider.isOutgoingMessage(message.sentTimestamp!!)) return // The message has been deleted
|
||||||
val attachmentIDs = mutableListOf<Long>()
|
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 attachments = attachmentIDs.mapNotNull { messageDataProvider.getDatabaseAttachment(it) }
|
||||||
val attachmentsToUpload = attachments.filter { it.url.isNullOrEmpty() }
|
val attachmentsToUpload = attachments.filter { it.url.isNullOrEmpty() }
|
||||||
attachmentsToUpload.forEach {
|
attachmentsToUpload.forEach {
|
||||||
if (MessagingModuleConfiguration.shared.storage.getAttachmentUploadJob(it.attachmentId.rowId) != null) {
|
if (storage.getAttachmentUploadJob(it.attachmentId.rowId) != null) {
|
||||||
// Wait for it to finish
|
// Wait for it to finish
|
||||||
} else {
|
} else {
|
||||||
val job = AttachmentUploadJob(it.attachmentId.rowId, message.threadID!!.toString(), message, id!!)
|
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
|
return
|
||||||
} // Wait for all attachments to upload before continuing
|
} // 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 {
|
val promise = MessageSender.send(this.message, this.destination).success {
|
||||||
this.handleSuccess()
|
this.handleSuccess()
|
||||||
}.fail { exception ->
|
}.fail { exception ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user