fix(files): add silent mode in legacy navigation

Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
This commit is contained in:
Grigorii K. Shartsev 2023-10-31 00:21:56 +01:00
parent e4efb922b4
commit ef07975012
2 changed files with 12 additions and 6 deletions

View file

@ -216,10 +216,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 })
},
/**

View file

@ -200,16 +200,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)
}
}
},