Grab most recent attributes when saving messages in batchers

This commit is contained in:
trevor-signal 2023-12-15 13:04:08 -05:00 committed by GitHub
parent 36c4c6bfb0
commit a03aab14cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,13 @@ const updateMessageBatcher = createBatcher<MessageAttributesType>({
maxSize: 50,
processBatch: async (messageAttrs: Array<MessageAttributesType>) => {
log.info('updateMessageBatcher', messageAttrs.length);
await window.Signal.Data.saveMessages(messageAttrs, {
// Grab the latest from the cache in case they've changed
const messagesToSave = messageAttrs.map(
message => window.MessageCache.accessAttributes(message.id) ?? message
);
await window.Signal.Data.saveMessages(messagesToSave, {
ourAci: window.textsecure.storage.user.getCheckedAci(),
});
},
@ -40,7 +46,13 @@ export const saveNewMessageBatcher = createWaitBatcher<MessageAttributesType>({
maxSize: 30,
processBatch: async (messageAttrs: Array<MessageAttributesType>) => {
log.info('saveNewMessageBatcher', messageAttrs.length);
await window.Signal.Data.saveMessages(messageAttrs, {
// Grab the latest from the cache in case they've changed
const messagesToSave = messageAttrs.map(
message => window.MessageCache.accessAttributes(message.id) ?? message
);
await window.Signal.Data.saveMessages(messagesToSave, {
forceSave: true,
ourAci: window.textsecure.storage.user.getCheckedAci(),
});