Fix the UI being unresponsive during media restore.

This commit is contained in:
Greyson Parrelli
2025-11-03 09:49:47 -05:00
committed by Michelle Tang
parent 07f33d22bf
commit aed9b3afaa
2 changed files with 66 additions and 13 deletions

View File

@@ -1589,7 +1589,7 @@ class AttachmentTable(
* that the content of the attachment will never change.
*/
@Throws(MmsException::class)
fun finalizeAttachmentAfterDownload(mmsId: Long, attachmentId: AttachmentId, inputStream: InputStream, offloadRestoredAt: Duration? = null, archiveRestore: Boolean = false) {
fun finalizeAttachmentAfterDownload(mmsId: Long, attachmentId: AttachmentId, inputStream: InputStream, offloadRestoredAt: Duration? = null, archiveRestore: Boolean = false, notify: Boolean = true) {
Log.i(TAG, "[finalizeAttachmentAfterDownload] Finalizing downloaded data for $attachmentId. (MessageId: $mmsId, $attachmentId)")
val existingPlaceholder: DatabaseAttachment = getAttachment(attachmentId) ?: throw MmsException("No attachment found for id: $attachmentId")
@@ -1679,9 +1679,11 @@ class AttachmentTable(
threads.updateSnippetUriSilently(threadId, snippetMessageId = mmsId, attachment = PartAuthority.getAttachmentDataUri(attachmentId))
}
notifyConversationListeners(threadId)
notifyConversationListListeners()
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
if (notify) {
notifyConversationListeners(threadId)
notifyConversationListListeners()
AppDependencies.databaseObserver.notifyAttachmentUpdatedObservers()
}
if (foundDuplicate) {
if (!fileWriteResult.file.delete()) {