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");
|
throw new Error("_addAttachmentToMessage: sticker didn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
_replaceAttachment(sticker, 'data', attachment, logPrefix);
|
message.set({
|
||||||
|
sticker: {
|
||||||
|
...sticker,
|
||||||
|
data: attachment,
|
||||||
|
},
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,11 @@ export type MessageType = {
|
||||||
received_at: number;
|
received_at: number;
|
||||||
hasSignalAccount?: boolean;
|
hasSignalAccount?: boolean;
|
||||||
attachments: Array<AttachmentType>;
|
attachments: Array<AttachmentType>;
|
||||||
|
sticker: {
|
||||||
|
data?: {
|
||||||
|
pending: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// No need to go beyond this; unused at this stage, since this goes into
|
// 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
|
// a reducer still in plain JavaScript and comes out well-formed
|
||||||
|
@ -517,22 +522,39 @@ function hasMessageHeightChanged(
|
||||||
message: MessageType,
|
message: MessageType,
|
||||||
previous: MessageType
|
previous: MessageType
|
||||||
): Boolean {
|
): Boolean {
|
||||||
const visualAttachmentNoLongerPending =
|
const messageAttachments = message.attachments || [];
|
||||||
previous.attachments &&
|
const previousAttachments = previous.attachments || [];
|
||||||
previous.attachments[0] &&
|
|
||||||
previous.attachments[0].pending &&
|
const stickerPendingChanged =
|
||||||
message.attachments &&
|
message.sticker &&
|
||||||
message.attachments.length === 1 &&
|
message.sticker.data &&
|
||||||
message.attachments[0] &&
|
previous.sticker &&
|
||||||
(isImageAttachment(message.attachments[0]) ||
|
previous.sticker.data &&
|
||||||
isVideoAttachment(message.attachments[0])) &&
|
previous.sticker.data.pending !== message.sticker.data.pending;
|
||||||
!message.attachments[0].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 =
|
const signalAccountChanged =
|
||||||
Boolean(message.hasSignalAccount || previous.hasSignalAccount) &&
|
Boolean(message.hasSignalAccount || previous.hasSignalAccount) &&
|
||||||
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
|
// tslint:disable-next-line cyclomatic-complexity max-func-body-length
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue