Skip to content

Commit

Permalink
Merge pull request #41206 from nextcloud/fix/39565/race-condition-on-…
Browse files Browse the repository at this point in the history
…web-files-view

fix(files): race condition on web files view change
  • Loading branch information
ShGKme committed Oct 31, 2023
2 parents e85f616 + d439417 commit e9189e0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
6 changes: 4 additions & 2 deletions apps/files/js/app.js
Expand Up @@ -219,10 +219,12 @@
/**
* Sets the currently active view
* @param viewId view id
* @param {Object} options options
* @param {boolean} [options.silent=false] if true, the view will not be shown immediately
*/
setActiveView: function(viewId) {
setActiveView: function (viewId, { silent = false } = {}) {
// The Navigation API will handle the final event
window._nc_event_bus.emit('files:legacy-navigation:changed', { id: viewId })
window._nc_event_bus.emit('files:legacy-navigation:changed', { id: viewId, silent })
},

/**
Expand Down
7 changes: 0 additions & 7 deletions apps/files/js/filelist.js
Expand Up @@ -764,13 +764,6 @@
*/
_onShow: function(e) {
OCA.Files.App && OCA.Files.App.updateCurrentFileList(this);
if (e.itemId === this.id) {
this._setCurrentDir('/', false);
}
// Only reload if we don't navigate to a different directory
if (typeof e.dir === 'undefined' || e.dir === this.getCurrentDirectory()) {
this.reload();
}
},

/**
Expand Down
12 changes: 8 additions & 4 deletions apps/files/src/views/Navigation.vue
Expand Up @@ -228,16 +228,20 @@ export default {
* Coming from the legacy files app.
* TODO: remove when all views are migrated.
*
* @param {Navigation} view the new active view
* @param {object} payload the payload
* @param {string} [payload.id='files'] the view id
* @param {boolean} [payload.silent=false] if true, the view will not be shown immediately
*/
onLegacyNavigationChanged({ id } = { id: 'files' }) {
onLegacyNavigationChanged({ id = 'files', silent = false } = {}) {
const view = this.Navigation.views.find(view => view.id === id)
if (view && view.legacy && view.id !== this.currentView.id) {
// Force update the current route as the request comes
// from the legacy files app router
this.$router.replace({ ...this.$route, params: { view: view.id } })
this.Navigation.setActive(view)
this.showView(view)
if (!silent) {
this.Navigation.setActive(view)
this.showView(view)
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit e9189e0

Please sign in to comment.