From d9212108a3c0d2e69e37f80167a8886a9fa59814 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 12 Feb 2024 11:13:09 -0800 Subject: [PATCH] modifyTargetMessage: Save other changes before applying edits --- ts/util/modifyTargetMessage.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ts/util/modifyTargetMessage.ts b/ts/util/modifyTargetMessage.ts index 104f2bb35ce1..67477eb21761 100644 --- a/ts/util/modifyTargetMessage.ts +++ b/ts/util/modifyTargetMessage.ts @@ -250,6 +250,14 @@ export async function modifyTargetMessage( }) ); + // We save here before handling any edits because handleEditMessage does its own saves + if (changed && !isFirstRun) { + log.info(`${logId}: Changes in second run; saving.`); + await window.Signal.Data.saveMessage(message.attributes, { + ourAci, + }); + } + // We want to make sure the message is saved first before applying any edits if (!isFirstRun && !skipEdits) { const edits = Edits.forMessage(message.attributes); @@ -262,11 +270,4 @@ export async function modifyTargetMessage( ) ); } - - if (changed && !isFirstRun) { - log.info(`${logId}: Changes in second run; saving.`); - await window.Signal.Data.saveMessage(message.attributes, { - ourAci, - }); - } }