From 5fbe5d1ff57f51736ec17fad539a9b3cee9f6eda Mon Sep 17 00:00:00 2001 From: Jorrin Date: Fri, 19 Apr 2024 19:26:29 +0200 Subject: [PATCH] fix tmdb 404 request --- src/components/player/atoms/NextEpisodeButton.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/player/atoms/NextEpisodeButton.tsx b/src/components/player/atoms/NextEpisodeButton.tsx index 270d03f0..ca92f418 100644 --- a/src/components/player/atoms/NextEpisodeButton.tsx +++ b/src/components/player/atoms/NextEpisodeButton.tsx @@ -49,7 +49,7 @@ function Button(props: { function useSeasons(mediaId: string, isLastEpisode: boolean = false) { const state = useAsync(async () => { if (isLastEpisode) { - const data = await getMetaFromId(MWMediaType.SERIES, mediaId ?? ""); + const data = await getMetaFromId(MWMediaType.SERIES, mediaId); if (data?.meta.type !== MWMediaType.SERIES) return null; return data.meta.seasons; } @@ -64,9 +64,10 @@ function useNextSeasonEpisode( ) { const state = useAsync(async () => { if (nextSeason) { + if (!mediaId) return; const data = await getMetaFromId( MWMediaType.SERIES, - mediaId ?? "", + mediaId, nextSeason?.id, ); if (data?.meta.type !== MWMediaType.SERIES) return null; @@ -106,7 +107,9 @@ export function NextEpisodeButton(props: { const enableAutoplay = usePreferencesStore((s) => s.enableAutoplay); const isLastEpisode = - meta?.episode?.number === meta?.episodes?.at(-1)?.number; + !meta?.episode?.number || !meta?.episodes?.at(-1)?.number + ? false + : meta.episode.number === meta.episodes.at(-1)!.number; const seasons = useSeasons(meta?.tmdbId ?? "", isLastEpisode);