diff --git a/src/Pages/ShowEpisode.vue b/src/Pages/ShowEpisode.vue index f94f078ffcd41a61de050414ae7f0d95671d582f..dbc8e0035f1a4f36d63b863e341f1c0e67135273 100644 --- a/src/Pages/ShowEpisode.vue +++ b/src/Pages/ShowEpisode.vue @@ -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,