aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/router
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-07-01 21:35:50 +0200
committerGitHub <noreply@github.com>2025-07-01 21:35:50 +0200
commitc89856b2fa7281421fc8e86cb67223d75a890fe4 (patch)
tree4b9dd1c240a2b30288e920ddd9ce30b542a171c7 /apps/files/src/router
parenteabbde31c77c16ca0a6648d7f6d29d23c92dc931 (diff)
parent541f5503b654c8546bd85afd24d4ac46566281a6 (diff)
downloadnextcloud-server-master.tar.gz
nextcloud-server-master.zip
Merge pull request #53662 from nextcloud/feat/search-in-filesHEADmaster
feat(files): allow to proper search in files
Diffstat (limited to 'apps/files/src/router')
-rw-r--r--apps/files/src/router/router.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/files/src/router/router.ts b/apps/files/src/router/router.ts
index 00f08c38d31..20c252d6954 100644
--- a/apps/files/src/router/router.ts
+++ b/apps/files/src/router/router.ts
@@ -11,7 +11,6 @@ import Router, { isNavigationFailure, NavigationFailureType } from 'vue-router'
import Vue from 'vue'
import { useFilesStore } from '../store/files'
-import { useNavigation } from '../composables/useNavigation'
import { usePathsStore } from '../store/paths'
import logger from '../logger'
@@ -74,14 +73,27 @@ const router = new Router({
},
})
+// Handle aborted navigation (NavigationGuards) gracefully
+router.onError((error) => {
+ if (isNavigationFailure(error, NavigationFailureType.aborted)) {
+ logger.debug('Navigation was aboorted', { error })
+ } else {
+ throw error
+ }
+})
+
// If navigating back from a folder to a parent folder,
// we need to keep the current dir fileid so it's highlighted
// and scrolled into view.
-router.beforeEach((to, from, next) => {
+router.beforeResolve((to, from, next) => {
if (to.params?.parentIntercept) {
delete to.params.parentIntercept
- next()
- return
+ return next()
+ }
+
+ if (to.params.view !== from.params.view) {
+ // skip if different views
+ return next()
}
const fromDir = (from.query?.dir || '/') as string
@@ -89,17 +101,16 @@ router.beforeEach((to, from, next) => {
// We are going back to a parent directory
if (relative(fromDir, toDir) === '..') {
- const { currentView } = useNavigation()
const { getNode } = useFilesStore()
const { getPath } = usePathsStore()
- if (!currentView.value?.id) {
+ if (!from.params.view) {
logger.error('No current view id found, cannot navigate to parent directory', { fromDir, toDir })
return next()
}
// Get the previous parent's file id
- const fromSource = getPath(currentView.value?.id, fromDir)
+ const fromSource = getPath(from.params.view, fromDir)
if (!fromSource) {
logger.error('No source found for the parent directory', { fromDir, toDir })
return next()
@@ -112,7 +123,7 @@ router.beforeEach((to, from, next) => {
}
logger.debug('Navigating back to parent directory', { fromDir, toDir, fileId })
- next({
+ return next({
name: 'filelist',
query: to.query,
params: {