Move to MessageCache.saveMessage, queue downloads piecemeal

This commit is contained in:
Scott Nonnenberg 2025-01-24 06:37:18 -10:00 committed by GitHub
parent 197660a966
commit ed30059bd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 138 additions and 298 deletions

View file

@ -190,7 +190,7 @@ import { migrateLegacyReadStatus } from '../messages/migrateLegacyReadStatus';
import { migrateLegacySendAttributes } from '../messages/migrateLegacySendAttributes';
import { getIsInitialSync } from '../services/contactSync';
import { queueAttachmentDownloadsForMessage } from '../util/queueAttachmentDownloads';
import { cleanupMessages, postSaveUpdates } from '../util/cleanup';
import { cleanupMessages } from '../util/cleanup';
import { MessageModel } from './messages';
/* eslint-disable more/no-then */
@ -2015,11 +2015,7 @@ export class ConversationModel extends window.Backbone
if (updated) {
upgraded += 1;
const ourAci = window.textsecure.storage.user.getCheckedAci();
await DataWriter.saveMessage(model.attributes, {
ourAci,
postSaveUpdates,
});
await window.MessageCache.saveMessage(model.attributes);
}
return model.attributes;
@ -2270,7 +2266,6 @@ export class ConversationModel extends window.Backbone
options: { isLocalAction?: boolean } = {}
): Promise<void> {
const { isLocalAction } = options;
const ourAci = window.textsecure.storage.user.getCheckedAci();
let messages: Array<MessageAttributesType> | undefined;
do {
@ -2324,10 +2319,7 @@ export class ConversationModel extends window.Backbone
const shouldSave =
await queueAttachmentDownloadsForMessage(registered);
if (shouldSave) {
await DataWriter.saveMessage(registered.attributes, {
ourAci,
postSaveUpdates,
});
await window.MessageCache.saveMessage(registered.attributes);
}
})
);