Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] fix(files): race condition on web files view change #41206

Merged
merged 3 commits into from Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.