Merge pull request #1671 from oxen-io/fix/attachment-anrs

Moving the heavy lifting code in a coroutine to help with ANRs
This commit is contained in:
ThomasSession 2024-09-16 15:07:27 +10:00 committed by GitHub
commit f35f30a3b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1785,10 +1785,21 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
attachmentManager.clear() attachmentManager.clear()
// Reset attachments button if needed // Reset attachments button if needed
if (isShowingAttachmentOptions) { toggleAttachmentOptions() } if (isShowingAttachmentOptions) { toggleAttachmentOptions() }
// Put the message in the database
message.id = mmsDb.insertMessageOutbox(outgoingTextMessage, viewModel.threadId, false, null, runThreadUpdate = true) // do the heavy work in the bg
// Send it lifecycleScope.launch(Dispatchers.IO) {
MessageSender.send(message, recipient.address, attachments, quote, linkPreview) // Put the message in the database
message.id = mmsDb.insertMessageOutbox(
outgoingTextMessage,
viewModel.threadId,
false,
null,
runThreadUpdate = true
)
// Send it
MessageSender.send(message, recipient.address, attachments, quote, linkPreview)
}
// Send a typing stopped message // Send a typing stopped message
ApplicationContext.getInstance(this).typingStatusSender.onTypingStopped(viewModel.threadId) ApplicationContext.getInstance(this).typingStatusSender.onTypingStopped(viewModel.threadId)
return Pair(recipient.address, sentTimestamp) return Pair(recipient.address, sentTimestamp)