Skip to content
Snippets Groups Projects
Commit 6adfc3d8 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

refactor: let pages explicitly handle route parameter behaviour

parent f69d6491
No related branches found
No related tags found
No related merge requests found
......@@ -113,18 +113,10 @@ function useRouteSyncBehaviour(
if (!oldShow) return
const newShowId = show?.id ?? null
const oldShowId = oldShow?.id ?? null
if (newShowId === oldShowId && newShowId === null) return
if (newShowId === oldShowId) return
if (show && route.name && route.params.showId) {
if (Object.values(route.params).length === 1) {
// The route only contains the showId, so we can safely navigate to the same route
// but with a different show.
void router.replace({ name: route.name, params: { ...route.params, showId: newShowId } })
} else {
// This route contains other parameters that may depend on the currently selected show.
// Navigate to the default show detail page instead.
void router.push({ name: 'show', params: { showId: newShowId } })
}
void router.replace({ name: route.name, params: { ...route.params, showId: newShowId } })
}
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment