fix: always navigate to Series screen when exiting playback from Episode

Instead of just popping the EpisodeRoute (which could land on Home if
opened from ContinueWatching), pop and push a SeriesRoute so playback
exit consistently returns to the SeriesScreen.
This commit is contained in:
2026-03-03 21:26:03 +01:00
parent 12fdf977a4
commit cf078c760e
2 changed files with 10 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import hu.bbara.purefin.core.data.AppContentRepository
import hu.bbara.purefin.core.data.navigation.NavigationManager
import hu.bbara.purefin.core.data.navigation.Route
import hu.bbara.purefin.core.data.navigation.SeriesDto
import hu.bbara.purefin.core.model.Episode
import hu.bbara.purefin.feature.download.DownloadState
import hu.bbara.purefin.feature.download.MediaDownloadManager
@@ -27,6 +28,7 @@ class EpisodeScreenViewModel @Inject constructor(
): ViewModel() {
private val _episodeId = MutableStateFlow<UUID?>(null)
private val _seriesId = MutableStateFlow<UUID?>(null)
val episode: StateFlow<Episode?> = combine(
_episodeId,
@@ -47,8 +49,15 @@ class EpisodeScreenViewModel @Inject constructor(
navigationManager.navigate(Route.PlayerRoute(mediaId = id))
}
fun onPlaybackStarted() {
val seriesId = _seriesId.value ?: return
navigationManager.pop()
navigationManager.navigate(Route.SeriesRoute(SeriesDto(id = seriesId)))
}
fun selectEpisode(seriesId: UUID, seasonId: UUID, episodeId: UUID) {
_episodeId.value = episodeId
_seriesId.value = seriesId
viewModelScope.launch {
mediaDownloadManager.observeDownloadState(episodeId.toString()).collect {
_downloadState.value = it