feat(files_versions): Auto-reload versions tab on file

Listen for files:node:updated events and automatically refresh the
versions list when the current file is saved, eliminating the need to
manually close and reopen the sidebar to see new versions.

Signed-off-by: silver <s.szmajduch@posteo.de>
This commit is contained in:
silver 2026-01-27 11:13:22 +01:00 committed by Arthur Schiwon
parent 767082772f
commit 930a399000

View file

@ -142,11 +142,28 @@ export default {
},
mounted() {
subscribe('files_versions:restore:restored', this.fetchVersions)
subscribe('files:node:updated', this.handleNodeUpdated)
},
beforeUnmount() {
unsubscribe('files_versions:restore:restored', this.fetchVersions)
unsubscribe('files:node:updated', this.handleNodeUpdated)
},
methods: {
/**
* Handle files:node:updated event to reload versions when the current file is saved
*
* @param {object} node The updated node
*/
handleNodeUpdated(node) {
// Reload if this is the currently open file
if (this.fileInfo && node.fileid === this.fileInfo.id) {
// Delay to let the server create the new version
setTimeout(() => {
this.fetchVersions()
}, 1000)
}
},
/**
* Update current fileInfo and fetch new data
*