From 9b3aa45d897f50f79dded8033712f85a9a0d9ec9 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Thu, 11 Jul 2024 22:28:19 -0400 Subject: [PATCH] Have navigation guards return true or explicitly call next --- frontend/src/plugins/router.ts | 7 ++++--- frontend/src/views/Gallery/Collection.vue | 4 +++- frontend/src/views/Gallery/Platform.vue | 4 +++- frontend/src/views/GameDetails.vue | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/plugins/router.ts b/frontend/src/plugins/router.ts index 1291986c8..8c172d948 100644 --- a/frontend/src/plugins/router.ts +++ b/frontend/src/plugins/router.ts @@ -77,12 +77,13 @@ const router = createRouter({ routes, }); -router.beforeEach((to) => { +router.beforeEach((to, _from, next) => { const heartbeat = storeHeartbeat(); if (to.name == "setup" && !heartbeat.value.SHOW_SETUP_WIZARD) { - router.push({ name: "dashboard" }); + next({ name: "dashboard" }); + } else { + next(); } - // TODO: check permission for views. Ex: view user can access to /scan view }); router.afterEach(() => { diff --git a/frontend/src/views/Gallery/Collection.vue b/frontend/src/views/Gallery/Collection.vue index 6ce41e320..4632be5d9 100644 --- a/frontend/src/views/Gallery/Collection.vue +++ b/frontend/src/views/Gallery/Collection.vue @@ -226,7 +226,7 @@ onMounted(async () => { onBeforeRouteUpdate(async (to, from) => { // Triggers when change param of the same route // Reset store if switching to another collection - if (to.path === from.path) return; + if (to.path === from.path) return true; resetGallery(); @@ -241,6 +241,8 @@ onBeforeRouteUpdate(async (to, from) => { await fetchRoms(); setFilters(); + + return true; }); onBeforeUnmount(() => { diff --git a/frontend/src/views/Gallery/Platform.vue b/frontend/src/views/Gallery/Platform.vue index 922ed504e..175dea7ad 100644 --- a/frontend/src/views/Gallery/Platform.vue +++ b/frontend/src/views/Gallery/Platform.vue @@ -227,7 +227,7 @@ onMounted(async () => { onBeforeRouteUpdate(async (to, from) => { // Triggers when change param of the same route // Reset store if switching to another platform - if (to.path === from.path) return; + if (to.path === from.path) return true; resetGallery(); @@ -242,6 +242,8 @@ onBeforeRouteUpdate(async (to, from) => { await fetchRoms(); setFilters(); + + return true; }); onBeforeUnmount(() => { diff --git a/frontend/src/views/GameDetails.vue b/frontend/src/views/GameDetails.vue index cd25045ac..1f19cfcbf 100644 --- a/frontend/src/views/GameDetails.vue +++ b/frontend/src/views/GameDetails.vue @@ -84,6 +84,7 @@ onBeforeMount(async () => { onBeforeRouteLeave(() => { currentRom.value = null; + return true; }); watch(