Merge pull request #996 from rommapp/fix-nav-guards-returns

Have navigation guards return true or explicitly call next
This commit is contained in:
Zurdi
2024-07-12 08:21:04 +02:00
committed by GitHub
4 changed files with 11 additions and 5 deletions

View File

@@ -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(() => {

View File

@@ -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(() => {

View File

@@ -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(() => {

View File

@@ -84,6 +84,7 @@ onBeforeMount(async () => {
onBeforeRouteLeave(() => {
currentRom.value = null;
return true;
});
watch(