Schedule media downloads after successful transaction.
This commit is contained in:
parent
4a9a07a9ef
commit
0817f113c6
2 changed files with 26 additions and 20 deletions
|
@ -874,21 +874,23 @@ object DataMessageProcessor {
|
|||
}
|
||||
|
||||
return if (insertResult != null) {
|
||||
val allAttachments = SignalDatabase.attachments.getAttachmentsForMessage(insertResult.messageId)
|
||||
val stickerAttachments = allAttachments.filter { it.isSticker }.toList()
|
||||
val attachments = allAttachments.filterNot { it.isSticker }.toList()
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
val allAttachments = SignalDatabase.attachments.getAttachmentsForMessage(insertResult.messageId)
|
||||
val stickerAttachments = allAttachments.filter { it.isSticker }.toList()
|
||||
val otherAttachments = allAttachments.filterNot { it.isSticker }.toList()
|
||||
|
||||
forceStickerDownloadIfNecessary(context, insertResult.messageId, stickerAttachments)
|
||||
forceStickerDownloadIfNecessary(context, insertResult.messageId, stickerAttachments)
|
||||
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(insertResult.messageId, attachment.attachmentId, false))
|
||||
}
|
||||
for (attachment in otherAttachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(insertResult.messageId, attachment.attachmentId, false))
|
||||
}
|
||||
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context, ConversationId.forConversation(insertResult.threadId))
|
||||
TrimThreadJob.enqueueAsync(insertResult.threadId)
|
||||
|
||||
if (message.isViewOnce) {
|
||||
ApplicationDependencies.getViewOnceMessageManager().scheduleIfNecessary()
|
||||
if (message.isViewOnce) {
|
||||
ApplicationDependencies.getViewOnceMessageManager().scheduleIfNecessary()
|
||||
}
|
||||
}
|
||||
|
||||
MessageId(insertResult.messageId)
|
||||
|
|
|
@ -404,8 +404,10 @@ object SyncMessageProcessor {
|
|||
SignalDatabase.messages.endTransaction()
|
||||
}
|
||||
if (syncAttachments.isNotEmpty()) {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -511,9 +513,10 @@ object SyncMessageProcessor {
|
|||
} finally {
|
||||
SignalDatabase.messages.endTransaction()
|
||||
}
|
||||
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,13 +802,14 @@ object SyncMessageProcessor {
|
|||
} finally {
|
||||
SignalDatabase.messages.endTransaction()
|
||||
}
|
||||
SignalDatabase.runPostSuccessfulTransaction {
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
}
|
||||
|
||||
for (attachment in attachments) {
|
||||
ApplicationDependencies.getJobManager().add(AttachmentDownloadJob(messageId, attachment.attachmentId, false))
|
||||
DataMessageProcessor.forceStickerDownloadIfNecessary(context, messageId, stickerAttachments)
|
||||
}
|
||||
|
||||
DataMessageProcessor.forceStickerDownloadIfNecessary(context, messageId, stickerAttachments)
|
||||
|
||||
return threadId
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue