From 964972a07d15151d6cc1572a1a0eb44bc62457a9 Mon Sep 17 00:00:00 2001 From: Konrad Mohrfeldt <km@roko.li> Date: Fri, 24 Jan 2025 15:45:19 +0100 Subject: [PATCH] fix: redirect to episode overview if episode cannot be found --- src/Pages/ShowEpisode.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Pages/ShowEpisode.vue b/src/Pages/ShowEpisode.vue index f94f078..dbc8e00 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, -- GitLab