Fix uncaught error in copyStickerToAttachments

This commit is contained in:
Fedor Indutny 2021-10-07 10:08:55 -07:00 committed by GitHub
parent 0f9242670c
commit 0d5ef38e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -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);

View File

@ -2222,7 +2222,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
}
const absolutePath = getAbsoluteAttachmentPath(firstAttachment.path);
const tempPath = await copyIntoTempDirectory(absolutePath);
const { path: tempPath } = await copyIntoTempDirectory(absolutePath);
const tempAttachment = {
...firstAttachment,
path: tempPath,

13
ts/window.d.ts vendored
View File

@ -303,7 +303,14 @@ declare global {
writeNewAttachmentData: (data: Uint8Array) => Promise<string>;
deleteExternalMessageFiles: (attributes: unknown) => Promise<void>;
getAbsoluteAttachmentPath: (path: string) => string;
loadAttachmentData: (attachment: WhatIsThis) => WhatIsThis;
loadAttachmentData: <T extends { path?: string }>(
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<DownloadedAttachmentType>;
copyIntoTempDirectory: any;
copyIntoTempDirectory: (
path: string
) => Promise<{ path: string; size: number }>;
deleteDraftFile: (path: string) => Promise<void>;
deleteTempFile: (path: string) => Promise<void>;
getAbsoluteDraftPath: any;