fix: do not schedule store update when deleting msgs

pull/3281/head
Audric Ackermann 5 months ago
parent 3e34b0f77f
commit 53e579427a
No known key found for this signature in database

@ -263,7 +263,7 @@ async function removeMessage(id: string): Promise<void> {
// it needs to delete all associated on-disk files along with the database delete. // it needs to delete all associated on-disk files along with the database delete.
if (message) { if (message) {
await channels.removeMessage(id); 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++) { for (let index = 0; index < messages.length; index++) {
const message = messages.at(index); const message = messages.at(index);
// eslint-disable-next-line no-await-in-loop // 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( window.log.info(
`removeAllMessagesInConversation messages.cleanup() ${conversationId} took ${ `removeAllMessagesInConversation messages.cleanup() ${conversationId} took ${

@ -472,10 +472,10 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
return ''; return '';
} }
public async cleanup() { public async cleanup(triggerUIUpdate: boolean) {
const changed = await deleteExternalMessageFiles(this.attributes); const changed = await deleteExternalMessageFiles(this.attributes);
if (changed) { if (changed) {
await this.commit(); await this.commit(triggerUIUpdate);
} }
} }

@ -46,7 +46,7 @@ export async function destroyMessagesAndUpdateRedux(
// TODO make this use getMessagesById and not getMessageById // TODO make this use getMessagesById and not getMessageById
const message = await Data.getMessageById(messageIds[i]); 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 */ /* eslint-enable no-await-in-loop */
} }

Loading…
Cancel
Save