Improve story cleanup on expiration/deletion
This commit is contained in:
parent
39d15ba620
commit
bde4fa40fe
4 changed files with 16 additions and 15 deletions
|
@ -264,13 +264,12 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
async hydrateStoryContext(
|
async hydrateStoryContext(
|
||||||
inMemoryMessage?: MessageAttributesType,
|
inMemoryMessage?: MessageAttributesType,
|
||||||
{
|
options: {
|
||||||
shouldSave,
|
|
||||||
}: {
|
|
||||||
shouldSave?: boolean;
|
shouldSave?: boolean;
|
||||||
|
isStoryErased?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await hydrateStoryContext(this.id, inMemoryMessage, { shouldSave });
|
await hydrateStoryContext(this.id, inMemoryMessage, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependencies of prop-generation functions
|
// Dependencies of prop-generation functions
|
||||||
|
|
|
@ -139,8 +139,10 @@ async function cleanupStoryReplies(
|
||||||
reply,
|
reply,
|
||||||
'cleanupStoryReplies/1:1'
|
'cleanupStoryReplies/1:1'
|
||||||
);
|
);
|
||||||
model.set('storyReplyContext', undefined);
|
await model.hydrateStoryContext(story, {
|
||||||
await model.hydrateStoryContext(story, { shouldSave: true });
|
shouldSave: true,
|
||||||
|
isStoryErased: true,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -157,9 +159,7 @@ export async function deleteMessageData(
|
||||||
await window.Signal.Migrations.deleteExternalMessageFiles(message);
|
await window.Signal.Migrations.deleteExternalMessageFiles(message);
|
||||||
|
|
||||||
if (isStory(message)) {
|
if (isStory(message)) {
|
||||||
// Attachments have been deleted from disk; remove from memory before replies update
|
await cleanupStoryReplies(message);
|
||||||
const storyWithoutAttachments = { ...message, attachments: undefined };
|
|
||||||
await cleanupStoryReplies(storyWithoutAttachments);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { sticker } = message;
|
const { sticker } = message;
|
||||||
|
|
|
@ -13,10 +13,6 @@ export function getStoryReplyText(
|
||||||
return i18n('icu:Quote__story-unavailable');
|
return i18n('icu:Quote__story-unavailable');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment.caption) {
|
|
||||||
return attachment.caption;
|
|
||||||
}
|
|
||||||
|
|
||||||
const attachments = [attachment];
|
const attachments = [attachment];
|
||||||
|
|
||||||
if (isImage(attachments)) {
|
if (isImage(attachments)) {
|
||||||
|
|
|
@ -14,8 +14,10 @@ export async function hydrateStoryContext(
|
||||||
storyMessageParam?: MessageAttributesType,
|
storyMessageParam?: MessageAttributesType,
|
||||||
{
|
{
|
||||||
shouldSave,
|
shouldSave,
|
||||||
|
isStoryErased,
|
||||||
}: {
|
}: {
|
||||||
shouldSave?: boolean;
|
shouldSave?: boolean;
|
||||||
|
isStoryErased?: boolean;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
let messageAttributes: MessageAttributesType;
|
let messageAttributes: MessageAttributesType;
|
||||||
|
@ -35,7 +37,11 @@ export async function hydrateStoryContext(
|
||||||
|
|
||||||
const { storyReplyContext: context } = messageAttributes;
|
const { storyReplyContext: context } = messageAttributes;
|
||||||
// We'll continue trying to get the attachment as long as the message still exists
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +58,7 @@ export async function hydrateStoryContext(
|
||||||
storyMessage = undefined;
|
storyMessage = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storyMessage) {
|
if (!storyMessage || isStoryErased) {
|
||||||
const conversation = window.ConversationController.get(
|
const conversation = window.ConversationController.get(
|
||||||
messageAttributes.conversationId
|
messageAttributes.conversationId
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue