From 45c1ceca270afabd2e1ca012d6e7374b32d4f00d Mon Sep 17 00:00:00 2001 From: Damontecres Date: Sun, 13 Sep 2026 20:09:08 -0400 Subject: [PATCH] Fix favorites not querying for people & fix restoring focus on search page for discover items (#1961) ## Description Fix two bugs: - Favorites page didn't query for favorite people, introduced by #1864 - Fixes restoring focus on the search page after clicking a discover item and going back ### Related issues N/A ### Testing Emulator ## Screenshots N/A ## AI or LLM usage None --- .../damontecres/wholphin/ui/detail/FavoritesViewModel.kt | 4 +++- .../github/damontecres/wholphin/ui/search/SearchPage.kt | 2 +- .../damontecres/wholphin/ui/search/SearchViewModel.kt | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/FavoritesViewModel.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/FavoritesViewModel.kt index 8471c40d..adbd9a44 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/detail/FavoritesViewModel.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/detail/FavoritesViewModel.kt @@ -787,7 +787,9 @@ fun List.possibleFavoriteTypes(sort: Boolean) = flatMap { it.collectionType.baseItemKinds } .distinct() .filter { it in favoriteOptions } - .let { list -> + .let { + // No library for persons, so always include it + val list = it + listOf(BaseItemKind.PERSON) if (sort) { list.sortedWith(compareBy { favoriteOptions.indexOf(it) }) } else { diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchPage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchPage.kt index e353287d..f20222d9 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchPage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchPage.kt @@ -113,7 +113,7 @@ fun SearchPage( val focusRequesters = remember(state.includedSearchableTypes.size) { List(RESULTS_START + state.includedSearchableTypes.size) { FocusRequester() } } - val seerrActive by viewModel.seerrActive.collectAsState(initial = false) + val seerrActive by viewModel.seerrActive.collectAsState() var selectedTab by rememberSaveable(seerrActive, state.discoverEnabled) { mutableIntStateOf(0) } var showViewOptions by rememberSaveable { mutableStateOf(false) } var showFilterTypeDialog by rememberSaveable { mutableStateOf(false) } diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchViewModel.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchViewModel.kt index 81dfa95f..044178b2 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchViewModel.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/search/SearchViewModel.kt @@ -43,9 +43,11 @@ import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CancellationException import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull +import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import org.jellyfin.sdk.api.client.ApiClient @@ -79,7 +81,12 @@ class SearchViewModel private val navDrawerService: NavDrawerService, ) : ViewModel(), ContextMenuProvider { - val seerrActive = seerrService.active + val seerrActive = + seerrService.active.stateIn( + scope = viewModelScope, + started = SharingStarted.Eagerly, + initialValue = false, + ) private val _state = MutableStateFlow(SearchState()) val state: StateFlow = _state