From 43ebb2acf52ad56499a8ee9c7c0871097d75bc7c Mon Sep 17 00:00:00 2001 From: "Grigorii K. Shartsev" Date: Thu, 8 Oct 2026 18:43:01 +0200 Subject: [PATCH] fix(files): edited files marked locked in files list after close Signed-off-by: Grigorii K. Shartsev --- src/components/CollaborativeEditor.vue | 10 ++++++++++ src/services/SyncService.ts | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/CollaborativeEditor.vue b/src/components/CollaborativeEditor.vue index 4a57e7311da..e9a2cd5b891 100644 --- a/src/components/CollaborativeEditor.vue +++ b/src/components/CollaborativeEditor.vue @@ -767,6 +767,7 @@ export default defineComponent({ onSave() { if (this.fileNode) { + // Cheap file update for Files app while the editor is still open this.fileNode.mtime = new Date() this.fileNode.size = new Blob([this.serialize()]).size emit('files:node:updated', this.fileNode) @@ -836,6 +837,15 @@ export default defineComponent({ logger.warn('Failed to destroy editor', { error }) } } + + // Update the file in Files with the latest size, mtime, the lock state + if (this.fileNode) { + const updatedNode = await fetchNode(this.fileNode) + .catch((err) => logger.warn('Failed to fetch node', { err })) + if (updatedNode) { + emit('files:node:updated', updatedNode) + } + } }, /** @param {Event} event The passed event */ diff --git a/src/services/SyncService.ts b/src/services/SyncService.ts index 51d3d35eea8..7cb75f45728 100644 --- a/src/services/SyncService.ts +++ b/src/services/SyncService.ts @@ -287,16 +287,20 @@ class SyncService { async close() { this.backend?.disconnect() - if (this.hasActiveConnection()) { - close(this.connection.value) + + const activeConnection = this.connection.value + + // Clear connection immediately so hasActiveConnection turns false and we can reconnect. + this.connection.value = undefined + this.bus.emit('close') + + if (activeConnection) { + await close(activeConnection) // Log and ignore possible network issues. .catch((e) => { logger.info('Failed to close connection.', { e }) }) } - // Clear connection so hasActiveConnection turns false and we can reconnect. - this.connection.value = undefined - this.bus.emit('close') } }