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
This commit is contained in:
Damontecres 2026-09-17 14:41:45 -04:00 • committed by GitHub
parent 32a56e8387
commit 170989c31e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 -> {