Fixes & optimizations to series pages (#106)

Simplifies the process for finding the right season id & episode id
after clicking on an episode. This can also improve loading time for
seasons that have a large number of episodes (hundreds).

Also fixes handling for "unknown" seasons which don't have an
index/season number.
This commit is contained in:
damontecres 2025-10-29 11:02:21 -04:00 committed by GitHub
parent 808e379e02
commit 576c20edff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 130 additions and 118 deletions

View file

@ -1,6 +1,6 @@
package com.github.damontecres.wholphin.data.model
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisode
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.util.seasonEpisode
import kotlinx.serialization.Serializable
@ -54,27 +54,23 @@ data class BaseItem(
// Redirect episodes & seasons to their series if possible
when (type) {
BaseItemKind.EPISODE -> {
indexNumber?.let { episode ->
data.parentIndexNumber?.let { season ->
Destination.SeriesOverview(
data.seriesId!!,
BaseItemKind.SERIES,
this,
SeasonEpisode(season, episode),
)
}
} ?: Destination.MediaItem(id, type, this)
}
BaseItemKind.SEASON ->
data.indexNumber?.let { season ->
data.seasonId?.let { seasonId ->
Destination.SeriesOverview(
data.seriesId!!,
BaseItemKind.SERIES,
this,
SeasonEpisode(season, 0),
SeasonEpisodeIds(seasonId, data.parentIndexNumber, id, indexNumber),
)
} ?: Destination.MediaItem(id, type, this)
}
BaseItemKind.SEASON ->
Destination.SeriesOverview(
data.seriesId!!,
BaseItemKind.SERIES,
this,
SeasonEpisodeIds(id, indexNumber, null, null),
)
else -> Destination.MediaItem(id, type, this)
}