Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(frontend:files): detect unsaved draw.io changes before closing
johaven1fbc47046f4d
diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.tsindex ade88cbf..24f3ad01 100644--- a/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-drawio.component.ts@@ -90,6 +90,7 @@ export class FilesViewerDrawioComponent extends FilesViewerEditableBase implemen// Coalesce those events into one follow-up upload containing the latest XML.private savePending = falseprivate closeAfterSave = false+ private closeCheckPending = falseconstructor() {super()@@ -150,6 +151,13 @@ export class FilesViewerDrawioComponent extends FilesViewerEditableBase implemencase 'autosave':if (typeof data.xml === 'string') this.trackChanges(data.xml)break+ case 'export':+ if (this.closeCheckPending && typeof data.xml === 'string') {+ this.closeCheckPending = false+ this.trackChanges(data.xml)+ super.requestClose()+ }+ breakcase 'exit':this.requestClose()break@@ -258,13 +266,15 @@ export class FilesViewerDrawioComponent extends FilesViewerEditableBase implementhis.isModified.set(this.content !== this.savedContent)}- private requestClose() {- if (this.isSaving()) return- if (this.isModified() && !this.isReadonly()) {- this.warnOnUnsavedChanges.set(true)- } else {- this.onClose().catch(console.error)+ protected override requestClose() {+ if (this.isSaving() || this.closeCheckPending) return+ if (this.isReadonlyView()) {+ super.requestClose()+ return}+ this.closeCheckPending = true+ this.postToEditor({ action: 'resetEditor' })+ this.postToEditor({ action: 'export', format: 'xml' })}private persist() {diff --git a/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts b/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.tsindex 7124303a..bcb9e2f5 100644--- a/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts+++ b/frontend/src/app/applications/files/components/viewers/files-viewer-editable-base.ts@@ -59,16 +59,7 @@ export abstract class FilesViewerEditableBase implements AfterViewInit, OnDestroprotected constructor() {effect(() => {if (!this.modalClosing()) return- const fileId = untracked(() => this.file().id)- const modified = untracked(() => this.isModified())- if (modified) {- this.warnOnUnsavedChanges.set(true)- if (this.layout.windows.getValue().find((w: AppWindow) => w.id === fileId)) {- this.layout.restoreDialog(fileId)- }- } else {- this.onClose().catch(console.error)- }+ untracked(() => this.requestClose())})}@@ -169,6 +160,18 @@ export abstract class FilesViewerEditableBase implements AfterViewInit, OnDestroreturn !document.activeElement?.closest('.files-viewer-search')}+ protected requestClose(): void {+ const fileId = this.file().id+ if (this.isModified()) {+ this.warnOnUnsavedChanges.set(true)+ if (this.layout.windows.getValue().find((w: AppWindow) => w.id === fileId)) {+ this.layout.restoreDialog(fileId)+ }+ } else {+ this.onClose().catch(console.error)+ }+ }+protected hideTooltips(): void {this.tooltips().forEach((tooltip: TooltipDirective) => tooltip.hide())}