mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
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:
parent
767082772f
commit
930a399000
1 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue