mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
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:
parent
f9ff04c5b7
commit
dac0b7208c
2 changed files with 24 additions and 6 deletions
|
|
@ -132,6 +132,14 @@ fun SeriesDetails(
|
||||||
var showPlaylistDialog by remember { mutableStateOf<Optional<UUID>>(Optional.absent()) }
|
var showPlaylistDialog by remember { mutableStateOf<Optional<UUID>>(Optional.absent()) }
|
||||||
var showDeleteDialog by remember { mutableStateOf<BaseItem?>(null) }
|
var showDeleteDialog by remember { mutableStateOf<BaseItem?>(null) }
|
||||||
|
|
||||||
|
LifecycleResumeEffect(destination.itemId) {
|
||||||
|
viewModel.refresh()
|
||||||
|
|
||||||
|
onPauseOrDispose {
|
||||||
|
viewModel.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
when (val state = loading) {
|
when (val state = loading) {
|
||||||
is LoadingState.Error -> {
|
is LoadingState.Error -> {
|
||||||
ErrorMessage(state, modifier)
|
ErrorMessage(state, modifier)
|
||||||
|
|
@ -148,9 +156,7 @@ fun SeriesDetails(
|
||||||
LifecycleResumeEffect(destination.itemId) {
|
LifecycleResumeEffect(destination.itemId) {
|
||||||
viewModel.onResumePage()
|
viewModel.onResumePage()
|
||||||
|
|
||||||
onPauseOrDispose {
|
onPauseOrDispose {}
|
||||||
viewModel.release()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val played = item.data.userData?.played ?: false
|
val played = item.data.userData?.played ?: false
|
||||||
|
|
|
||||||
|
|
@ -271,9 +271,9 @@ class SeriesViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onResumePage() {
|
fun onResumePage() {
|
||||||
|
item.value?.let { item ->
|
||||||
|
viewModelScope.launchDefault { backdropService.submit(item) }
|
||||||
viewModelScope.launchIO {
|
viewModelScope.launchIO {
|
||||||
item.value?.let {
|
|
||||||
backdropService.submit(it)
|
|
||||||
val playThemeSongs =
|
val playThemeSongs =
|
||||||
userPreferencesService
|
userPreferencesService
|
||||||
.getCurrent()
|
.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() {
|
fun release() {
|
||||||
themeSongPlayer.stop()
|
themeSongPlayer.stop()
|
||||||
}
|
}
|
||||||
|
|
@ -292,6 +303,7 @@ class SeriesViewModel
|
||||||
seasonNum: Int?,
|
seasonNum: Int?,
|
||||||
): Deferred<List<BaseItem?>> =
|
): Deferred<List<BaseItem?>> =
|
||||||
viewModelScope.async(Dispatchers.IO) {
|
viewModelScope.async(Dispatchers.IO) {
|
||||||
|
Timber.v("getSeasons for %s", series.id)
|
||||||
val request =
|
val request =
|
||||||
GetItemsRequest(
|
GetItemsRequest(
|
||||||
parentId = series.id,
|
parentId = series.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue