diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 5ea7d90bb..f49c1c44c 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -264,13 +264,12 @@ export class MessageModel extends window.Backbone.Model { async hydrateStoryContext( inMemoryMessage?: MessageAttributesType, - { - shouldSave, - }: { + options: { shouldSave?: boolean; + isStoryErased?: boolean; } = {} ): Promise { - await hydrateStoryContext(this.id, inMemoryMessage, { shouldSave }); + await hydrateStoryContext(this.id, inMemoryMessage, options); } // Dependencies of prop-generation functions diff --git a/ts/util/cleanup.ts b/ts/util/cleanup.ts index 11dac01c8..8e354f94e 100644 --- a/ts/util/cleanup.ts +++ b/ts/util/cleanup.ts @@ -139,8 +139,10 @@ async function cleanupStoryReplies( reply, 'cleanupStoryReplies/1:1' ); - model.set('storyReplyContext', undefined); - await model.hydrateStoryContext(story, { shouldSave: true }); + await model.hydrateStoryContext(story, { + shouldSave: true, + isStoryErased: true, + }); }) ); } @@ -157,9 +159,7 @@ export async function deleteMessageData( await window.Signal.Migrations.deleteExternalMessageFiles(message); if (isStory(message)) { - // Attachments have been deleted from disk; remove from memory before replies update - const storyWithoutAttachments = { ...message, attachments: undefined }; - await cleanupStoryReplies(storyWithoutAttachments); + await cleanupStoryReplies(message); } const { sticker } = message; diff --git a/ts/util/getStoryReplyText.ts b/ts/util/getStoryReplyText.ts index a7dfb4088..a39ce414f 100644 --- a/ts/util/getStoryReplyText.ts +++ b/ts/util/getStoryReplyText.ts @@ -13,10 +13,6 @@ export function getStoryReplyText( return i18n('icu:Quote__story-unavailable'); } - if (attachment.caption) { - return attachment.caption; - } - const attachments = [attachment]; if (isImage(attachments)) { diff --git a/ts/util/hydrateStoryContext.ts b/ts/util/hydrateStoryContext.ts index 67ef4ae82..d7ab7313e 100644 --- a/ts/util/hydrateStoryContext.ts +++ b/ts/util/hydrateStoryContext.ts @@ -14,8 +14,10 @@ export async function hydrateStoryContext( storyMessageParam?: MessageAttributesType, { shouldSave, + isStoryErased, }: { shouldSave?: boolean; + isStoryErased?: boolean; } = {} ): Promise { let messageAttributes: MessageAttributesType; @@ -35,7 +37,11 @@ export async function hydrateStoryContext( const { storyReplyContext: context } = messageAttributes; // We'll continue trying to get the attachment as long as the message still exists - if (context && (context.attachment?.url || !context.messageId)) { + if ( + !isStoryErased && + context && + (context.attachment?.url || !context.messageId) + ) { return; } @@ -52,7 +58,7 @@ export async function hydrateStoryContext( storyMessage = undefined; } - if (!storyMessage) { + if (!storyMessage || isStoryErased) { const conversation = window.ConversationController.get( messageAttributes.conversationId );