Save modified messages for edits
Co-authored-by: Josh Perez <josh.p@signal.org>
This commit is contained in:
@@ -2367,7 +2367,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||||||
return modifyTargetMessage(this, conversation, {
|
return modifyTargetMessage(this, conversation, {
|
||||||
isFirstRun,
|
isFirstRun,
|
||||||
skipEdits: false,
|
skipEdits: false,
|
||||||
skipSave: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -342,7 +342,6 @@ export async function handleEditMessage(
|
|||||||
await modifyTargetMessage(mainMessageModel, mainMessageConversation, {
|
await modifyTargetMessage(mainMessageModel, mainMessageConversation, {
|
||||||
isFirstRun: false,
|
isFirstRun: false,
|
||||||
skipEdits: true,
|
skipEdits: true,
|
||||||
skipSave: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,13 +35,9 @@ import { strictAssert } from './assert';
|
|||||||
export async function modifyTargetMessage(
|
export async function modifyTargetMessage(
|
||||||
message: MessageModel,
|
message: MessageModel,
|
||||||
conversation: ConversationModel,
|
conversation: ConversationModel,
|
||||||
options?: { isFirstRun: boolean; skipEdits: boolean; skipSave: boolean }
|
options?: { isFirstRun: boolean; skipEdits: boolean }
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const {
|
const { isFirstRun = false, skipEdits = false } = options ?? {};
|
||||||
isFirstRun = false,
|
|
||||||
skipEdits = false,
|
|
||||||
skipSave = false,
|
|
||||||
} = options ?? {};
|
|
||||||
|
|
||||||
const logId = `modifyTargetMessage/${message.idForLogging()}`;
|
const logId = `modifyTargetMessage/${message.idForLogging()}`;
|
||||||
const type = message.get('type');
|
const type = message.get('type');
|
||||||
@@ -267,7 +263,7 @@ export async function modifyTargetMessage(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skipSave && changed && !isFirstRun) {
|
if (changed && !isFirstRun) {
|
||||||
log.info(`${logId}: Changes in second run; saving.`);
|
log.info(`${logId}: Changes in second run; saving.`);
|
||||||
await window.Signal.Data.saveMessage(message.attributes, {
|
await window.Signal.Data.saveMessage(message.attributes, {
|
||||||
ourAci,
|
ourAci,
|
||||||
|
Reference in New Issue
Block a user