Refresh seasons on series details page (#1123)

## Description
Simply fetches the tv show's seasons when returning the details page.
This ensures the unwatched counts are updated.

### Related issues
Mentioned as a bug in
https://github.com/damontecres/Wholphin/issues/767#issuecomment-4071852502

### Testing
Emulator

## Screenshots
N/A

## AI or LLM usage
None
This commit is contained in:
Ray 2026-03-20 12:07:28 -04:00 committed by GitHub
parent f9ff04c5b7
commit dac0b7208c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 6 deletions

View file

@ -132,6 +132,14 @@ fun SeriesDetails(
var showPlaylistDialog by remember { mutableStateOf<Optional<UUID>>(Optional.absent()) }
var showDeleteDialog by remember { mutableStateOf<BaseItem?>(null) }
LifecycleResumeEffect(destination.itemId) {
viewModel.refresh()
onPauseOrDispose {
viewModel.release()
}
}
when (val state = loading) {
is LoadingState.Error -> {
ErrorMessage(state, modifier)
@ -148,9 +156,7 @@ fun SeriesDetails(
LifecycleResumeEffect(destination.itemId) {
viewModel.onResumePage()
onPauseOrDispose {
viewModel.release()
}
onPauseOrDispose {}
}
val played = item.data.userData?.played ?: false

View file

@ -271,9 +271,9 @@ class SeriesViewModel
}
fun onResumePage() {
viewModelScope.launchIO {
item.value?.let {
backdropService.submit(it)
item.value?.let { item ->
viewModelScope.launchDefault { backdropService.submit(item) }
viewModelScope.launchIO {
val playThemeSongs =
userPreferencesService
.getCurrent()
@ -283,6 +283,17 @@ class SeriesViewModel
}
}
fun refresh() {
item.value?.let { item ->
if (loading.value == LoadingState.Success) {
viewModelScope.launchIO {
val seasons = getSeasons(item, null).await()
this@SeriesViewModel.seasons.setValueOnMain(seasons)
}
}
}
}
fun release() {
themeSongPlayer.stop()
}
@ -292,6 +303,7 @@ class SeriesViewModel
seasonNum: Int?,
): Deferred<List<BaseItem?>> =
viewModelScope.async(Dispatchers.IO) {
Timber.v("getSeasons for %s", series.id)
val request =
GetItemsRequest(
parentId = series.id,