diff --git a/src/components/AppToolbar.tsx b/src/components/AppToolbar.tsx index cc993d23..ca12aa50 100644 --- a/src/components/AppToolbar.tsx +++ b/src/components/AppToolbar.tsx @@ -3,7 +3,6 @@ import classnames from 'classnames' import {detect} from 'detect-browser'; import { - MdFileDownload, MdOpenInBrowser, MdSettings, MdLayers, diff --git a/src/components/ModalExport.tsx b/src/components/ModalExport.tsx index 697be76f..aba7fa09 100644 --- a/src/components/ModalExport.tsx +++ b/src/components/ModalExport.tsx @@ -82,29 +82,29 @@ class ModalExportInternal extends React.Component { } async saveStyle() { - const fileHandle = null; + let fileHandle: FileSystemFileHandle; const tokenStyle = this.tokenizedStyle(); if (fileHandle != null) { const writable = await fileHandle.createWritable(); await writable.write(tokenStyle); - writable.flush(); await writable.close(); } else { - // TODO + await this.saveStyleAs(); } } async saveStyleAs() { - const fileHandle = null; const tokenStyle = this.tokenizedStyle(); const root = await navigator.storage.getDirectory(); const draftHandle = await root.getFileHandle(this.exportName(), { create: true }); - const accessHandle = await draftHandle.createSyncAccessHandle(); + const writeable = await draftHandle.createWritable(); - accessHandle.write(tokenStyle); - accessHandle.flush(); + await writeable.write(tokenStyle); + await writeable.close(); + // TODO close existing fileHandle + // TODO this.props.fileHandle = accessHandle; } changeMetadataProperty(property: string, value: any) { diff --git a/src/components/ModalOpen.tsx b/src/components/ModalOpen.tsx index fbe5c5fd..4415175c 100644 --- a/src/components/ModalOpen.tsx +++ b/src/components/ModalOpen.tsx @@ -137,6 +137,7 @@ class ModalOpenInternal extends React.Component { this.clearError(); + // TODO close existing file handles const pickerOpts = { types: [ @@ -149,7 +150,7 @@ class ModalOpenInternal extends React.Component; const file = await fileHandle.getFile(); const content = await file.text();