diff --git a/js/modules/attachment_downloads.js b/js/modules/attachment_downloads.js index ad43eecaac..5338e962c5 100644 --- a/js/modules/attachment_downloads.js +++ b/js/modules/attachment_downloads.js @@ -406,7 +406,12 @@ async function _addAttachmentToMessage(message, attachment, { type, index }) { throw new Error("_addAttachmentToMessage: sticker didn't exist"); } - _replaceAttachment(sticker, 'data', attachment, logPrefix); + message.set({ + sticker: { + ...sticker, + data: attachment, + }, + }); return; } diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 965a7b4a34..6a672551e5 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -59,6 +59,11 @@ export type MessageType = { received_at: number; hasSignalAccount?: boolean; attachments: Array; + sticker: { + data?: { + pending: boolean; + }; + }; // No need to go beyond this; unused at this stage, since this goes into // a reducer still in plain JavaScript and comes out well-formed @@ -517,22 +522,39 @@ function hasMessageHeightChanged( message: MessageType, previous: MessageType ): Boolean { - const visualAttachmentNoLongerPending = - previous.attachments && - previous.attachments[0] && - previous.attachments[0].pending && - message.attachments && - message.attachments.length === 1 && - message.attachments[0] && - (isImageAttachment(message.attachments[0]) || - isVideoAttachment(message.attachments[0])) && - !message.attachments[0].pending; + const messageAttachments = message.attachments || []; + const previousAttachments = previous.attachments || []; + + const stickerPendingChanged = + message.sticker && + message.sticker.data && + previous.sticker && + previous.sticker.data && + previous.sticker.data.pending !== message.sticker.data.pending; + if (stickerPendingChanged) { + return true; + } + + const singleVisualAttachmentNoLongerPending = + messageAttachments.length === 1 && + previousAttachments[0] && + previousAttachments[0].pending && + messageAttachments[0] && + (isImageAttachment(messageAttachments[0]) || + isVideoAttachment(messageAttachments[0])) && + !messageAttachments[0].pending; + if (singleVisualAttachmentNoLongerPending) { + return true; + } const signalAccountChanged = Boolean(message.hasSignalAccount || previous.hasSignalAccount) && message.hasSignalAccount !== previous.hasSignalAccount; + if (signalAccountChanged) { + return true; + } - return visualAttachmentNoLongerPending || signalAccountChanged; + return false; } // tslint:disable-next-line cyclomatic-complexity max-func-body-length