A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: handle errors when saving attachment
Abdullah Attab92bc03fa970
diff --git a/apps/web/src/common/attachments.ts b/apps/web/src/common/attachments.tsindex 4054262c8..08502c7fe 100644--- a/apps/web/src/common/attachments.ts+++ b/apps/web/src/common/attachments.ts@@ -44,19 +44,27 @@ async function download(hash: string, groupId?: string) {}export async function saveAttachment(hash: string) {- const response = await download(hash);- if (!response) return;-- const { attachment, key } = response;- await lazify(import("../interfaces/fs"), ({ saveFile }) =>- saveFile(attachment.hash, {- key,- iv: attachment.iv,- name: attachment.filename,- type: attachment.mimeType,- isUploaded: !!attachment.dateUploaded- })- );+ try {+ const response = await download(hash);+ if (!response) return;++ const { attachment, key } = response;+ await lazify(import("../interfaces/fs"), ({ saveFile }) =>+ saveFile(attachment.hash, {+ key,+ iv: attachment.iv,+ name: attachment.filename,+ type: attachment.mimeType,+ isUploaded: !!attachment.dateUploaded+ })+ );+ } catch (e) {+ console.error(e);+ showToast(+ "error",+ `Failed to download attachment: ${hash} (error: ${(e as Error).message})`+ );+ }}type OutputTypeToReturnType = {