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

fix: redirect to episode overview if episode cannot be found

parent fe85d7b2
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ const router = useRouter()
const route = useRoute()
const episodeStore = useEpisodeStore()
const mediaStore = useMediaStore()
const { obj: episode } = useObjectFromStore(
const { obj: episode, isLoading: isLoadingEpisode } = useObjectFromStore(
() => parseInt(route.params.episodeId as string),
episodeStore,
)
......@@ -27,6 +27,13 @@ const { obj: media } = useObjectFromStore(() => episode.value?.mediaId ?? null,
defineNavigationContext(() => ({ episode }))
watchEffect(() => {
if (!episode.value && !isLoadingEpisode.value) {
// if the episode could not be found redirect to the overview page
void router.push({ name: 'show-episodes', params: { showId: props.show.id.toString() } })
}
})
watchEffect(() => {
const showId = episode.value?.showId
// if episode.showId doesn’t match the provided show.id,
......
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