Improve quoted attachment typings

This commit is contained in:
trevor-signal 2024-05-23 17:06:41 -04:00 committed by GitHub
parent 38226115a4
commit 5f0080a7d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 98 additions and 97 deletions

View file

@ -6,6 +6,7 @@ import type { EditAttributesType } from '../messageModifiers/Edits';
import type {
EditHistoryType,
MessageAttributesType,
QuotedAttachmentType,
QuotedMessageType,
} from '../model-types.d';
import type { LinkPreviewType } from '../types/message/LinkPreviews';
@ -143,7 +144,7 @@ export async function handleEditMessage(
// and they have already been downloaded.
const attachmentSignatures: Map<string, AttachmentType> = new Map();
const previewSignatures: Map<string, LinkPreviewType> = new Map();
const quoteSignatures: Map<string, AttachmentType> = new Map();
const quoteSignatures: Map<string, QuotedAttachmentType> = new Map();
mainMessage.attachments?.forEach(attachment => {
const signature = getAttachmentSignatureSafe(attachment);
@ -226,13 +227,13 @@ export async function handleEditMessage(
return attachment;
}
const signature = getAttachmentSignatureSafe(attachment.thumbnail);
const existingThumbnail = signature
const existingQuoteAttachment = signature
? quoteSignatures.get(signature)
: undefined;
if (existingThumbnail) {
if (existingQuoteAttachment) {
return {
...attachment,
thumbnail: existingThumbnail,
thumbnail: existingQuoteAttachment.thumbnail,
};
}