Simplify PlaybackViewModel (#252)

`PlaybackViewModel` was becoming very unwieldy at over 1,300 LOC. This
PR breaks it up and simplifies some fields so it's easier to work with.

There are no user facing changes
This commit is contained in:
damontecres 2025-11-18 19:18:38 -05:00 committed by GitHub
parent 1fd497d18c
commit 4517dcd0cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 643 additions and 600 deletions

View file

@ -1,8 +1,10 @@
package com.github.damontecres.wholphin.data.model
import com.github.damontecres.wholphin.ui.detail.series.SeasonEpisodeIds
import com.github.damontecres.wholphin.ui.formatDateTime
import com.github.damontecres.wholphin.ui.nav.Destination
import com.github.damontecres.wholphin.ui.seasonEpisode
import com.github.damontecres.wholphin.ui.seasonEpisodePadded
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import org.jellyfin.sdk.api.client.ApiClient
@ -32,6 +34,18 @@ data class BaseItem(
get() =
if (type == BaseItemKind.EPISODE) data.seasonEpisode + " - " + name else data.productionYear?.toString()
val subtitleLong: String? by lazy {
if (type == BaseItemKind.EPISODE) {
buildList {
add(data.seasonEpisodePadded)
add(data.name)
add(data.premiereDate?.let { formatDateTime(it) })
}.filterNotNull().joinToString(" - ")
} else {
data.productionYear?.toString()
}
}
@Transient
val indexNumber = data.indexNumber ?: dateAsIndex()