fix: only show loader if the message isn't failed, fix attachment upload and message send pending states in the conversation

This commit is contained in:
jubb
2021-07-01 11:39:18 +10:00
parent ab876ca9b8
commit d98f34fa73
7 changed files with 20 additions and 19 deletions

View File

@@ -122,7 +122,7 @@ class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val mess
private fun handleFailure(e: Exception) {
Log.w(TAG, "Attachment upload failed due to error: $this.")
delegate?.handleJobFailed(this, e)
if (failureCount + 1 == maxFailureCount) {
if (failureCount + 1 >= maxFailureCount) {
failAssociatedMessageSendJob(e)
}
}

View File

@@ -37,6 +37,13 @@ class MessageSendJob(val message: Message, val destination: Destination) : Job {
val messageDataProvider = MessagingModuleConfiguration.shared.messageDataProvider
val message = message as? VisibleMessage
val storage = MessagingModuleConfiguration.shared.storage
val sentTimestamp = this.message.sentTimestamp
val sender = storage.getUserPublicKey()
if (sentTimestamp != null && sender != null) {
storage.markAsSending(sentTimestamp, sender)
}
if (message != null) {
if (!messageDataProvider.isOutgoingMessage(message.sentTimestamp!!)) return // The message has been deleted
val attachmentIDs = mutableListOf<Long>()
@@ -58,11 +65,6 @@ 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 ->