diff --git a/ts/background.ts b/ts/background.ts index 35b3de2a48c7..55ae986ec009 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -2102,7 +2102,10 @@ export async function startApp(): Promise { const attachmentsToDownload = attachmentDownloadQueue.filter( (message, index) => index <= MAX_ATTACHMENT_MSGS_TO_DOWNLOAD || - message.getReceivedAt() < THREE_DAYS_AGO + message.getReceivedAt() > THREE_DAYS_AGO || + // Stickers and long text attachments has to be downloaded for UI + // to display the message properly. + message.hasRequiredAttachmentDownloads() ); window.log.info( 'Downloading recent attachments of total attachments', diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 5c7f1ee9eba7..5a12fb807ae6 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -38,7 +38,7 @@ import { getCallingNotificationText, } from '../util/callingNotification'; import { PropsType as ProfileChangeNotificationPropsType } from '../components/conversation/ProfileChangeNotification'; -import { isImage, isVideo } from '../types/Attachment'; +import { AttachmentType, isImage, isVideo } from '../types/Attachment'; /* eslint-disable camelcase */ /* eslint-disable more/no-then */ @@ -2598,6 +2598,29 @@ export class MessageModel extends window.Backbone.Model { return this.syncPromise; } + hasRequiredAttachmentDownloads(): boolean { + const attachments: ReadonlyArray = + this.get('attachments') || []; + + const hasLongMessageAttachments = attachments.some(attachment => { + return ( + attachment.contentType === + window.Whisper.Message.LONG_MESSAGE_CONTENT_TYPE + ); + }); + + if (hasLongMessageAttachments) { + return true; + } + + const sticker = this.get('sticker'); + if (sticker) { + return !sticker.data || !sticker.data.path; + } + + return false; + } + // NOTE: If you're modifying this function then you'll likely also need // to modify queueAttachmentDownloads since it contains the logic below hasAttachmentDownloads(): boolean {