Code cleanup

This commit is contained in:
2026-02-22 19:08:28 +01:00
parent fe699d7f99
commit 318b190061
9 changed files with 44 additions and 323 deletions

View File

@@ -1,13 +1,8 @@
package hu.bbara.purefin.feature.shared.content.episode
import hu.bbara.purefin.core.model.CastMember
import org.jellyfin.sdk.model.UUID
data class CastMember(
val name: String,
val role: String,
val imageUrl: String?
)
data class EpisodeUiModel(
val id: UUID,
val title: String,

View File

@@ -1,24 +0,0 @@
package hu.bbara.purefin.feature.shared.content.movie
import org.jellyfin.sdk.model.UUID
data class CastMember(
val name: String,
val role: String,
val imageUrl: String?
)
data class MovieUiModel(
val id: UUID,
val title: String,
val year: String,
val rating: String,
val runtime: String,
val format: String,
val synopsis: String,
val heroImageUrl: String,
val audioTrack: String,
val subtitles: String,
val progress: Double?,
val cast: List<CastMember>
)

View File

@@ -23,7 +23,7 @@ class MovieScreenViewModel @Inject constructor(
private val mediaDownloadManager: MediaDownloadManager
): ViewModel() {
private val _movie = MutableStateFlow<MovieUiModel?>(null)
private val _movie = MutableStateFlow<Movie?>(null)
val movie = _movie.asStateFlow()
private val _downloadState = MutableStateFlow<DownloadState>(DownloadState.NotDownloaded)
@@ -44,12 +44,12 @@ class MovieScreenViewModel @Inject constructor(
fun selectMovie(movieId: UUID) {
viewModelScope.launch {
val movieData = mediaRepository.movies.value[movieId]
if (movieData == null) {
val movie = mediaRepository.movies.value[movieId]
if (movie == null) {
_movie.value = null
return@launch
}
_movie.value = movieData.toUiModel()
_movie.value = movie
launch {
mediaDownloadManager.observeDownloadState(movieId.toString()).collect {
@@ -76,21 +76,4 @@ class MovieScreenViewModel @Inject constructor(
}
}
private fun Movie.toUiModel(): MovieUiModel {
return MovieUiModel(
id = id,
title = title,
year = year,
rating = rating,
runtime = runtime,
format = format,
synopsis = synopsis,
heroImageUrl = heroImageUrl,
audioTrack = audioTrack,
subtitles = subtitles,
progress = progress,
cast = cast.map { CastMember(name = it.name, role = it.role, imageUrl = it.imageUrl) }
)
}
}

View File

@@ -1,48 +0,0 @@
package hu.bbara.purefin.feature.shared.content.series
data class SeriesEpisodeUiModel(
val id: String,
val title: String,
val seasonNumber: Int,
val episodeNumber: Int,
val description: String,
val duration: String,
val imageUrl: String,
val watched: Boolean,
val progress: Double?
)
data class SeriesSeasonUiModel(
val name: String,
val episodes: List<SeriesEpisodeUiModel>,
val unplayedCount: Int?
)
data class SeriesCastMemberUiModel(
val name: String,
val role: String,
val imageUrl: String?
)
data class SeriesUiModel(
val title: String,
val year: String,
val rating: String,
val seasons: String,
val format: String,
val synopsis: String,
val heroImageUrl: String,
val seasonTabs: List<SeriesSeasonUiModel>,
val cast: List<SeriesCastMemberUiModel>
) {
fun getNextEpisode(): SeriesEpisodeUiModel {
for (season in seasonTabs) {
for (episode in season.episodes) {
if (!episode.watched) {
return episode
}
}
}
return seasonTabs.first().episodes.first()
}
}