From 170989c31e2cfa8d7b295e3decc46eb96c4c92ca Mon Sep 17 00:00:00 2001 From: Damontecres Date: Thu, 17 Sep 2026 14:41:45 -0400 Subject: [PATCH] Guard against crash if episode has `seasonId` but no `seriesId` (#1964) ## Description When clicking on an episode, the app assumes if there is a season ID for the episode, then there must be a series ID. However, on my JF 12.0 server, an episode (with no metadata) appeared on my Continue Watching and it has a season ID (which in turn has a series ID) but no series ID. I'm not sure if this really a valid situation or if it's a server bug, but Wholphin shouldn't crash at least. So this PR checks both `seasonId` and `seriesId` and if either is null, falls back to the generic "Episode Page". Similarly, if a season has no `seriesId` (again, not sure if a valid situation), a crash won't occur, however there is no generic "Season Page", so an error page is shown. ### Related issues TODO, check JF server issues, maybe fixed in 12.1? ### Testing Emulator ## Screenshots N/a ## AI or LLM usage None --- .../wholphin/data/model/BaseItem.kt | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/data/model/BaseItem.kt b/app/src/main/java/com/github/damontecres/wholphin/data/model/BaseItem.kt index dd1236a4..eefb001b 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/data/model/BaseItem.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/data/model/BaseItem.kt @@ -237,21 +237,30 @@ data class BaseItem( // Redirect episodes & seasons to their series if possible when (type) { BaseItemKind.EPISODE -> { - data.seasonId?.let { seasonId -> + val seasonId = data.seasonId + val seriesId = data.seriesId + if (seasonId != null && seriesId != null) { Destination.SeriesOverview( - data.seriesId!!, + seriesId, BaseItemKind.SERIES, SeasonEpisodeIds(seasonId, data.parentIndexNumber, id, indexNumber), ) - } ?: Destination.MediaItem(this) + } else { + Destination.MediaItem(this) + } } BaseItemKind.SEASON -> { - Destination.SeriesOverview( - data.seriesId!!, - BaseItemKind.SERIES, - SeasonEpisodeIds(id, indexNumber, null, null), - ) + val seriesId = data.seriesId + if (seriesId != null) { + Destination.SeriesOverview( + seriesId, + BaseItemKind.SERIES, + SeasonEpisodeIds(id, indexNumber, null, null), + ) + } else { + Destination.MediaItem(this) + } } BaseItemKind.TV_CHANNEL -> {