fix: tags pill not hiding when tags disabled in Settings

- Initialize _tagsEnabled from preferences (was hardcoded true)
- Add refreshTagsEnabled() called when navigating to Home tab
- Immediately clears popularTags and activeTagFilter when disabled
This commit is contained in:
Paweł Orzech 2026-03-20 09:25:13 +01:00
parent 0718a9e744
commit 289082cb74
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View file

@ -79,7 +79,7 @@ class FeedViewModel(application: Application) : AndroidViewModel(application) {
private val _popularTags = MutableStateFlow<List<GhostTagFull>>(emptyList())
val popularTags: StateFlow<List<GhostTagFull>> = _popularTags.asStateFlow()
private val _tagsEnabled = MutableStateFlow(true)
private val _tagsEnabled = MutableStateFlow(tagsPreferences.isTagsEnabled())
val tagsEnabled: StateFlow<Boolean> = _tagsEnabled.asStateFlow()
private val _accounts = MutableStateFlow<List<GhostAccount>>(emptyList())
@ -343,6 +343,15 @@ class FeedViewModel(application: Application) : AndroidViewModel(application) {
}
}
fun refreshTagsEnabled() {
val enabled = tagsPreferences.isTagsEnabled()
_tagsEnabled.value = enabled
if (!enabled) {
_popularTags.value = emptyList()
_uiState.update { it.copy(activeTagFilter = null) }
}
}
fun filterByTag(tag: String) {
_uiState.update { it.copy(activeTagFilter = tag) }
refresh()

View file

@ -109,6 +109,7 @@ fun SwooshNavGraph(
onClick = {
if (item.route == Routes.FEED) {
feedViewModel.deactivateSearch()
feedViewModel.refreshTagsEnabled()
}
navController.navigate(item.route) {
popUpTo(navController.graph.findStartDestination().id) {