mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
web: handle file picker dialog cancelation
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user