From 0d5ef38e527850966600726dfd7bca56ffb86d3e Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:08:55 -0700 Subject: [PATCH] Fix uncaught error in copyStickerToAttachments --- ts/types/Stickers.ts | 4 +++- ts/views/conversation_view.ts | 2 +- ts/window.d.ts | 13 +++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ts/types/Stickers.ts b/ts/types/Stickers.ts index b1cff0a26a22..1ee39184e25a 100644 --- a/ts/types/Stickers.ts +++ b/ts/types/Stickers.ts @@ -769,7 +769,9 @@ export async function copyStickerToAttachments( size, } = await window.Signal.Migrations.copyIntoAttachmentsDirectory(absolutePath); - const data = window.Signal.Migrations.loadAttachmentData(path); + const { data } = await window.Signal.Migrations.loadAttachmentData({ + path, + }); let contentType: MIMEType; const sniffedMimeType = sniffImageMimeType(data); diff --git a/ts/views/conversation_view.ts b/ts/views/conversation_view.ts index 68f64d24570a..fe2cb90972e9 100644 --- a/ts/views/conversation_view.ts +++ b/ts/views/conversation_view.ts @@ -2222,7 +2222,7 @@ export class ConversationView extends window.Backbone.View { } const absolutePath = getAbsoluteAttachmentPath(firstAttachment.path); - const tempPath = await copyIntoTempDirectory(absolutePath); + const { path: tempPath } = await copyIntoTempDirectory(absolutePath); const tempAttachment = { ...firstAttachment, path: tempPath, diff --git a/ts/window.d.ts b/ts/window.d.ts index 0d49ece328d3..effb5f49de7d 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -303,7 +303,14 @@ declare global { writeNewAttachmentData: (data: Uint8Array) => Promise; deleteExternalMessageFiles: (attributes: unknown) => Promise; getAbsoluteAttachmentPath: (path: string) => string; - loadAttachmentData: (attachment: WhatIsThis) => WhatIsThis; + loadAttachmentData: ( + attachment: T + ) => Promise< + T & { + data: Uint8Array; + size: number; + } + >; loadQuoteData: (quote: unknown) => WhatIsThis; loadPreviewData: (preview: unknown) => WhatIsThis; loadStickerData: (sticker: unknown) => WhatIsThis; @@ -332,7 +339,9 @@ declare global { attachment: DownloadedAttachmentType ) => Promise; - copyIntoTempDirectory: any; + copyIntoTempDirectory: ( + path: string + ) => Promise<{ path: string; size: number }>; deleteDraftFile: (path: string) => Promise; deleteTempFile: (path: string) => Promise; getAbsoluteDraftPath: any;