瀏覽代碼

remove `fileHandle` from IDB if user rejects permission

dwelle 4 年之前
父節點
當前提交
f5f4ec7528
共有 1 個文件被更改,包括 13 次插入1 次删除
  1. 13 1
      src/actions/actionExport.tsx

+ 13 - 1
src/actions/actionExport.tsx

@@ -150,9 +150,21 @@ export const actionSaveToActiveFile = register({
       if (error?.name !== "AbortError") {
         console.error(error);
       }
+
+      if (fileHandleExists && error.name === "AbortError") {
+        try {
+          await idb.del(IDB_KEYS.fileHandle);
+        } catch (error) {
+          console.error(error);
+        }
+        return {
+          commitToHistory: false,
+          appState: { ...appState, fileHandle: null },
+        };
+      }
+
       return {
         commitToHistory: false,
-        appState: { ...appState, fileHandle: null },
       };
     }
   },