Skip to content

Commit

Permalink
Fix uncaught error in copyStickerToAttachments
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed Oct 7, 2021
1 parent 0f92426 commit 0d5ef38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ts/types/Stickers.ts
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ts/views/conversation_view.ts
Expand Up @@ -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,
Expand Down
13 changes: 11 additions & 2 deletions ts/window.d.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0d5ef38

Please sign in to comment.