From 5b6874b88226590c4449d2f3ddd25d3cf7a59ba3 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:48:52 -0400 Subject: [PATCH] Download your own story attachments. Hydrate story replies on receive --- ts/models/messages.ts | 7 ++++++- ts/util/shouldDownloadStory.ts | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 337fab00c3..60afa1e505 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -81,6 +81,7 @@ import { handleMessageSend } from '../util/handleMessageSend'; import { getSendOptions } from '../util/getSendOptions'; import { findAndFormatContact } from '../util/findAndFormatContact'; import { + getAttachmentsForMessage, getMessagePropStatus, getPropsForCallHistory, getPropsForMessage, @@ -357,7 +358,7 @@ export class MessageModel extends window.Backbone.Model { return; } - const attachments = message.get('attachments'); + const attachments = getAttachmentsForMessage({ ...message.attributes }); this.set({ storyReplyContext: { @@ -2444,6 +2445,10 @@ export class MessageModel extends window.Backbone.Model { storyId: dataMessage.storyId, }); + if (storyQuote) { + await this.hydrateStoryContext(storyQuote); + } + const isSupported = !isUnsupportedMessage(message.attributes); if (!isSupported) { await message.eraseContents(); diff --git a/ts/util/shouldDownloadStory.ts b/ts/util/shouldDownloadStory.ts index 54ad4bc2bf..de62b5dd8e 100644 --- a/ts/util/shouldDownloadStory.ts +++ b/ts/util/shouldDownloadStory.ts @@ -4,12 +4,18 @@ import type { ConversationAttributesType } from '../model-types.d'; import dataInterface from '../sql/Client'; +import { isMe } from './whatTypeOfConversation'; const MAX_NUM_STORIES_TO_PREFETCH = 5; export async function shouldDownloadStory( conversation: ConversationAttributesType ): Promise { + if (isMe(conversation)) { + return true; + } + + // We download the first time the user has posted a story if (!conversation.hasPostedStory) { return true; }