From 53e579427a515318e3041bc40013e5d71a206c7b Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 6 Jan 2025 13:27:19 +1100 Subject: [PATCH] fix: do not schedule store update when deleting msgs --- ts/data/data.ts | 4 ++-- ts/models/message.ts | 4 ++-- ts/session/disappearing_messages/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/data/data.ts b/ts/data/data.ts index 99ce43b28..a7bc155b4 100644 --- a/ts/data/data.ts +++ b/ts/data/data.ts @@ -263,7 +263,7 @@ async function removeMessage(id: string): Promise { // it needs to delete all associated on-disk files along with the database delete. if (message) { await channels.removeMessage(id); - await message.cleanup(); + await message.cleanup(true); } } @@ -554,7 +554,7 @@ async function removeAllMessagesInConversation(conversationId: string): Promise< for (let index = 0; index < messages.length; index++) { const message = messages.at(index); // eslint-disable-next-line no-await-in-loop - await message.cleanup(); + await message.cleanup(false); // not triggering UI updates, as we remove them from the store just below } window.log.info( `removeAllMessagesInConversation messages.cleanup() ${conversationId} took ${ diff --git a/ts/models/message.ts b/ts/models/message.ts index 0beff6b15..79b96fddc 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -472,10 +472,10 @@ export class MessageModel extends Backbone.Model { return ''; } - public async cleanup() { + public async cleanup(triggerUIUpdate: boolean) { const changed = await deleteExternalMessageFiles(this.attributes); if (changed) { - await this.commit(); + await this.commit(triggerUIUpdate); } } diff --git a/ts/session/disappearing_messages/index.ts b/ts/session/disappearing_messages/index.ts index 4a2f69afb..860916d2a 100644 --- a/ts/session/disappearing_messages/index.ts +++ b/ts/session/disappearing_messages/index.ts @@ -46,7 +46,7 @@ export async function destroyMessagesAndUpdateRedux( // TODO make this use getMessagesById and not getMessageById const message = await Data.getMessageById(messageIds[i]); - await message?.cleanup(); + await message?.cleanup(false); // not triggering UI updates, as we remove them from the store just below /* eslint-enable no-await-in-loop */ }