From 3cee0768cc0c3558bbfbc41b87edc5089caf6a92 Mon Sep 17 00:00:00 2001 From: Thomas Steiner Date: Mon, 15 Jun 2020 12:23:23 +0200 Subject: [PATCH] =?UTF-8?q?Null=20file=20handle=20doesn=E2=80=99t=20need?= =?UTF-8?q?=20to=20be=20passed=20(#1752)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump browser-nativefs version to v0.2.0 In reply to https://github.com/tomayac/browser-nativefs/issues/2. * Update package-lock.json * Null file handle doesn’t need to be passed --- src/data/json.ts | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/data/json.ts b/src/data/json.ts index 5eb68a52..3dbadde5 100644 --- a/src/data/json.ts +++ b/src/data/json.ts @@ -30,25 +30,16 @@ export const saveAsJSON = async ( const blob = new Blob([serialized], { type: "application/json", }); - // Either "Save as" or non-supporting browser - if (!fileHandle) { - const name = `${appState.name}.excalidraw`; - const handle = await fileSave( - blob, - { - fileName: name, - description: "Excalidraw file", - extensions: ["excalidraw"], - }, - fileHandle, - ); - (window as any).handle = handle; - return; - } - // "Save" - const writable = await fileHandle.createWritable(); - await writable.write(blob); - await writable.close(); + const name = `${appState.name}.excalidraw`; + (window as any).handle = await fileSave( + blob, + { + fileName: name, + description: "Excalidraw file", + extensions: ["excalidraw"], + }, + fileHandle || null, + ); }; export const loadFromJSON = async () => {