fix(files): properly handle viewer integration of sidebar

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2026-01-07 00:17:17 +01:00
parent 10661bf49f
commit 6491f6ec9a
No known key found for this signature in database
GPG key ID: 7E849AE05218500F
3 changed files with 15 additions and 3 deletions

View file

@ -33,6 +33,8 @@ declare module '@nextcloud/event-bus' {
'files:sidebar:opened': INode
'files:sidebar:closed': undefined
'viewer:sidebar:open': { source: string }
}
}

View file

@ -64,9 +64,7 @@ export default class RouterService {
query?: Record<string, string | (string | null)[] | null | undefined>,
replace?: boolean,
): Promise<Route> {
if (!name) {
name = this.router.currentRoute.name as string
}
name ??= this.router.currentRoute.name as string
const location: Location = { name, query, params }
if (replace) {
return this._router.replace(location)

View file

@ -11,6 +11,7 @@ import { defineStore } from 'pinia'
import { computed, ref, watch } from 'vue'
import logger from '../logger.ts'
import { useActiveStore } from './active.ts'
import { useFilesStore } from './files.ts'
export const useSidebarStore = defineStore('sidebar', () => {
const activeTab = ref<string>()
@ -127,6 +128,17 @@ export const useSidebarStore = defineStore('sidebar', () => {
}
})
subscribe('viewer:sidebar:open', ({ source }) => {
const filesStore = useFilesStore()
const node = filesStore.getNode(source)
if (node) {
logger.debug('Opening sidebar for node from Viewer.', { node })
open(node)
} else {
logger.error(`Cannot open sidebar for node '${source}' because it was not found in the current view.`)
}
})
let initialized = false
// close sidebar when parameter is removed from url
subscribe('files:list:updated', () => {