Recalculate message height when pending sticker is loaded
This commit is contained in:
parent
0beb1416d1
commit
936768d9c1
2 changed files with 39 additions and 12 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,11 @@ export type MessageType = {
|
|||
received_at: number;
|
||||
hasSignalAccount?: boolean;
|
||||
attachments: Array<AttachmentType>;
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue