diff --git a/state/state.ts b/state/state.ts index 74c7305e3..375a238c5 100644 --- a/state/state.ts +++ b/state/state.ts @@ -1499,7 +1499,6 @@ const state = createState({ }, forceSave(data) { - // storage.saveToLocalStorage(data) storage.saveToFileSystem(data) }, diff --git a/state/storage.ts b/state/storage.ts index c6139899a..5e8fa5534 100644 --- a/state/storage.ts +++ b/state/storage.ts @@ -122,10 +122,11 @@ class Storage { saveAsToFileSystem = (data: Data) => { // Create a new document id when saving to the file system + this.saveToFileSystem(data, uuid()) } - saveToFileSystem = (data: Data, id = data.document.id) => { + saveToFileSystem = (data: Data, id?: string) => { // Save to local storage first this.saveToLocalStorage(data, id) @@ -138,11 +139,15 @@ class Storage { fa.fileSave( blob, { - fileName: `${data.document.name}.tldr`, + fileName: `${ + id + ? data.document.name + : this.previousSaveHandle?.name || 'My Document' + }.tldr`, description: 'tldraw file', extensions: ['.tldr'], }, - this.previousSaveHandle, + id ? undefined : this.previousSaveHandle, true ) .then((handle) => {