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

View File

@@ -3,7 +3,6 @@ import classnames from 'classnames'
import {detect} from 'detect-browser';
import {
MdFileDownload,
MdOpenInBrowser,
MdSettings,
MdLayers,

View File

@@ -82,29 +82,29 @@ class ModalExportInternal extends React.Component<ModalExportInternalProps> {
}
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) {

View File

@@ -137,6 +137,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
onOpenFile = async () => {
this.clearError();
// TODO close existing file handles
const pickerOpts = {
types: [
@@ -149,7 +150,7 @@ class ModalOpenInternal extends React.Component<ModalOpenInternalProps, ModalOpe
multiple: false,
};
const [fileHandle] = await window.showOpenFilePicker(pickerOpts);
const [fileHandle] = await window.showOpenFilePicker(pickerOpts) as Array<FileSystemFileHandle>;
const file = await fileHandle.getFile();
const content = await file.text();