Fix favorite disable preference having no effect

This commit is contained in:
MM20 2022-09-23 22:40:58 +02:00
parent f16e9c2b40
commit 79be655949
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 5 additions and 2 deletions

View File

@ -57,6 +57,7 @@ fun SearchColumn(
var showWorkProfileApps by remember { mutableStateOf(false) }
val hideFavs by viewModel.hideFavorites.observeAsState(true)
val favoritesEnabled by viewModel.favoritesEnabled.collectAsState(false)
val apps by viewModel.appResults.observeAsState(emptyList())
val workApps by viewModel.workAppResults.observeAsState(emptyList())
val appShortcuts by viewModel.appShortcutResults.observeAsState(emptyList())
@ -80,7 +81,7 @@ fun SearchColumn(
contentPadding = paddingValues,
reverseLayout = reverse,
) {
if (!hideFavs) {
if (!hideFavs && favoritesEnabled) {
GridResults(
items = favorites.toImmutableList(),
columns = columns,
@ -101,7 +102,8 @@ fun SearchColumn(
Row(
modifier = Modifier
.weight(1f)
.horizontalScroll(tagsScrollState).padding(end = 12.dp),
.horizontalScroll(tagsScrollState)
.padding(end = 12.dp),
) {
FilterChip(
modifier = Modifier.padding(start = 16.dp),

View File

@ -66,6 +66,7 @@ class SearchVM : ViewModel(), KoinComponent {
val hiddenResults = MutableLiveData<List<Searchable>>(emptyList())
val favoritesEnabled = dataStore.data.map { it.favorites.enabled }
val hideFavorites = MutableLiveData(false)
private val hiddenItemKeys = favoritesRepository