Skip to content

Commit

Permalink
Download your own story attachments. Hydrate story replies on receive
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-signal committed Aug 10, 2022
1 parent 269d170 commit 5b6874b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ts/models/messages.ts
Expand Up @@ -81,6 +81,7 @@ import { handleMessageSend } from '../util/handleMessageSend';
import { getSendOptions } from '../util/getSendOptions';
import { findAndFormatContact } from '../util/findAndFormatContact';
import {
getAttachmentsForMessage,
getMessagePropStatus,
getPropsForCallHistory,
getPropsForMessage,
Expand Down Expand Up @@ -357,7 +358,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
return;
}

const attachments = message.get('attachments');
const attachments = getAttachmentsForMessage({ ...message.attributes });

this.set({
storyReplyContext: {
Expand Down Expand Up @@ -2444,6 +2445,10 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
storyId: dataMessage.storyId,
});

if (storyQuote) {
await this.hydrateStoryContext(storyQuote);
}

const isSupported = !isUnsupportedMessage(message.attributes);
if (!isSupported) {
await message.eraseContents();
Expand Down
6 changes: 6 additions & 0 deletions ts/util/shouldDownloadStory.ts
Expand Up @@ -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<boolean> {
if (isMe(conversation)) {
return true;
}

// We download the first time the user has posted a story
if (!conversation.hasPostedStory) {
return true;
}
Expand Down

0 comments on commit 5b6874b

Please sign in to comment.