Skip to content

Commit 1b455f4

Browse files
Merge pull request #58268 from nextcloud/repair-recovery
[stable32] feat(files_versions): Auto-reload versions tab on file
2 parents 7670827 + 1de0859 commit 1b455f4

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

apps/files_versions/src/views/VersionTab.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,28 @@ export default {
142142
},
143143
mounted() {
144144
subscribe('files_versions:restore:restored', this.fetchVersions)
145+
subscribe('files:node:updated', this.handleNodeUpdated)
145146
},
146147
beforeUnmount() {
147148
unsubscribe('files_versions:restore:restored', this.fetchVersions)
149+
unsubscribe('files:node:updated', this.handleNodeUpdated)
148150
},
149151
methods: {
152+
/**
153+
* Handle files:node:updated event to reload versions when the current file is saved
154+
*
155+
* @param {object} node The updated node
156+
*/
157+
handleNodeUpdated(node) {
158+
// Reload if this is the currently open file
159+
if (this.fileInfo && node.fileid === this.fileInfo.id && this.isActive && !this.loading) {
160+
// Delay to let the server create the new version
161+
setTimeout(() => {
162+
this.fetchVersions()
163+
}, 1000)
164+
}
165+
},
166+
150167
/**
151168
* Update current fileInfo and fetch new data
152169
*
@@ -172,6 +189,9 @@ export default {
172189
try {
173190
this.loading = true
174191
this.versions = await fetchVersions(this.fileInfo)
192+
} catch (error) {
193+
// Silently fail if we can't fetch versions (e.g., during user switch or permission issues)
194+
// The versions will be loaded when the tab is properly opened
175195
} finally {
176196
this.loading = false
177197
}

dist/files_versions-files_versions.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_versions-files_versions.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)