add todos, static typing

This commit is contained in:
Joscha
2025-01-06 17:56:59 +01:00
parent bf98926b39
commit 0251d7feba
3 changed files with 9 additions and 9 deletions
-1
View File
@@ -3,7 +3,6 @@ import classnames from 'classnames'
import {detect} from 'detect-browser'; import {detect} from 'detect-browser';
import { import {
MdFileDownload,
MdOpenInBrowser, MdOpenInBrowser,
MdSettings, MdSettings,
MdLayers, MdLayers,
+7 -7
View File
@@ -82,29 +82,29 @@ class ModalExportInternal extends React.Component<ModalExportInternalProps> {
} }
async saveStyle() { async saveStyle() {
const fileHandle = null; let fileHandle: FileSystemFileHandle;
const tokenStyle = this.tokenizedStyle(); const tokenStyle = this.tokenizedStyle();
if (fileHandle != null) { if (fileHandle != null) {
const writable = await fileHandle.createWritable(); const writable = await fileHandle.createWritable();
await writable.write(tokenStyle); await writable.write(tokenStyle);
writable.flush();
await writable.close(); await writable.close();
} else { } else {
// TODO await this.saveStyleAs();
} }
} }
async saveStyleAs() { async saveStyleAs() {
const fileHandle = null;
const tokenStyle = this.tokenizedStyle(); const tokenStyle = this.tokenizedStyle();
const root = await navigator.storage.getDirectory(); const root = await navigator.storage.getDirectory();
const draftHandle = await root.getFileHandle(this.exportName(), { create: true }); const draftHandle = await root.getFileHandle(this.exportName(), { create: true });
const accessHandle = await draftHandle.createSyncAccessHandle(); const writeable = await draftHandle.createWritable();
accessHandle.write(tokenStyle); await writeable.write(tokenStyle);
accessHandle.flush(); await writeable.close();
// TODO close existing fileHandle
// TODO this.props.fileHandle = accessHandle;
} }
changeMetadataProperty(property: string, value: any) { changeMetadataProperty(property: string, value: any) {
+2 -1
View File
@@ -137,6 +137,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
onOpenFile = async () => { onOpenFile = async () => {
this.clearError(); this.clearError();
// TODO close existing file handles
const pickerOpts = { const pickerOpts = {
types: [ types: [
@@ -149,7 +150,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
multiple: false, multiple: false,
}; };
const [fileHandle] = await window.showOpenFilePicker(pickerOpts); const [fileHandle] = await window.showOpenFilePicker(pickerOpts) as Array<FileSystemFileHandle>;
const file = await fileHandle.getFile(); const file = await fileHandle.getFile();
const content = await file.text(); const content = await file.text();