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 file picker dialog cancelation
Abdullah Atta233baf78ce75
diff --git a/apps/web/src/common/index.ts b/apps/web/src/common/index.tsindex 9fbcb7f5e..46dda2b8b 100644--- a/apps/web/src/common/index.ts+++ b/apps/web/src/common/index.ts@@ -138,8 +138,9 @@ export async function selectBackupFile() {export async function importBackup() {const backupFile = await selectBackupFile();- if (!backupFile) return;+ if (!backupFile) return false;await restoreBackupFile(backupFile);+ return true;}export async function restoreBackupFile(backupFile: File) {diff --git a/apps/web/src/dialogs/settings/backup-export-settings.ts b/apps/web/src/dialogs/settings/backup-export-settings.tsindex c008168da..6e3f05006 100644--- a/apps/web/src/dialogs/settings/backup-export-settings.ts+++ b/apps/web/src/dialogs/settings/backup-export-settings.ts@@ -67,8 +67,9 @@ export const BackupExportSettings: SettingsGroup[] = [type: "button",title: "Restore",action: async () => {- await importBackup();- await useAppStore.getState().refresh();+ if (await importBackup()) {+ await useAppStore.getState().refresh();+ }},variant: "secondary"}diff --git a/apps/web/src/utils/file-picker.ts b/apps/web/src/utils/file-picker.tsindex 840d47924..6b94e0dab 100644--- a/apps/web/src/utils/file-picker.ts+++ b/apps/web/src/utils/file-picker.ts@@ -30,6 +30,9 @@ export function showFilePicker({input.setAttribute("type", "file");input.setAttribute("accept", acceptedFileTypes);input.dispatchEvent(new MouseEvent("click"));+ input.oncancel = async function () {+ resolve(undefined);+ };input.onchange = async function () {if (!input.files) return resolve(undefined);const file = input.files[0];