Skip to content

Commit 77f9897

Browse files
committed
chore(files): adjust code for breaking change of Navigation.setActive
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 461d0ed commit 77f9897

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

apps/files/src/composables/useNavigation.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('Composables: useNavigation', () => {
4141
it('should return already active navigation', async () => {
4242
const view = new nextcloudFiles.View({ getContents: () => Promise.reject(new Error()), icon: '<svg></svg>', id: 'view-1', name: 'My View 1', order: 0 })
4343
navigation.register(view)
44-
navigation.setActive(view)
44+
navigation.setActive(view.id)
4545
// Now the navigation is already set it should take the active navigation
4646
const wrapper = mount(TestComponent)
4747
expect((wrapper.vm as unknown as { currentView: View | null }).currentView).toBe(view)
@@ -55,7 +55,7 @@ describe('Composables: useNavigation', () => {
5555
// no active navigation
5656
expect((wrapper.vm as unknown as { currentView: View | null }).currentView).toBe(null)
5757

58-
navigation.setActive(view)
58+
navigation.setActive(view.id)
5959
// Now the navigation is set it should take the active navigation
6060
expect((wrapper.vm as unknown as { currentView: View | null }).currentView).toBe(view)
6161
})

apps/files/src/views/FilesNavigation.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default defineComponent({
178178
showView(view: View) {
179179
// Closing any opened sidebar
180180
window.OCA?.Files?.Sidebar?.close?.()
181-
getNavigation().setActive(view)
181+
getNavigation().setActive(view.id)
182182
emit('files:navigation:changed', view)
183183
},
184184

apps/files_sharing/src/init-public.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type { Folder } from '@nextcloud/files'
2-
/**
1+
/*!
32
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
43
* SPDX-License-Identifier: AGPL-3.0-or-later
54
*/
5+
6+
import type { Folder } from '@nextcloud/files'
67
import type { ShareAttribute } from './sharing.d.ts'
78

89
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
@@ -22,7 +23,12 @@ registerPublicFileShareView()
2223
// Get the current view from state and set it active
2324
const view = loadState<string>('files_sharing', 'view')
2425
const navigation = getNavigation()
25-
navigation.setActive(navigation.views.find(({ id }) => id === view) ?? null)
26+
try {
27+
navigation.setActive(view)
28+
} catch {
29+
// no such view
30+
navigation.setActive(null)
31+
}
2632

2733
// Force our own router
2834
window.OCP.Files = window.OCP.Files ?? {}

0 commit comments

Comments
 (0)