mirror of
https://github.com/pawelorzech/Swoosh.git
synced 2026-03-31 20:15:41 +00:00
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:
parent
0718a9e744
commit
289082cb74
2 changed files with 11 additions and 1 deletions
|
|
@ -79,7 +79,7 @@ class FeedViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
private val _popularTags = MutableStateFlow<List<GhostTagFull>>(emptyList())
|
private val _popularTags = MutableStateFlow<List<GhostTagFull>>(emptyList())
|
||||||
val popularTags: StateFlow<List<GhostTagFull>> = _popularTags.asStateFlow()
|
val popularTags: StateFlow<List<GhostTagFull>> = _popularTags.asStateFlow()
|
||||||
|
|
||||||
private val _tagsEnabled = MutableStateFlow(true)
|
private val _tagsEnabled = MutableStateFlow(tagsPreferences.isTagsEnabled())
|
||||||
val tagsEnabled: StateFlow<Boolean> = _tagsEnabled.asStateFlow()
|
val tagsEnabled: StateFlow<Boolean> = _tagsEnabled.asStateFlow()
|
||||||
|
|
||||||
private val _accounts = MutableStateFlow<List<GhostAccount>>(emptyList())
|
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) {
|
fun filterByTag(tag: String) {
|
||||||
_uiState.update { it.copy(activeTagFilter = tag) }
|
_uiState.update { it.copy(activeTagFilter = tag) }
|
||||||
refresh()
|
refresh()
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ fun SwooshNavGraph(
|
||||||
onClick = {
|
onClick = {
|
||||||
if (item.route == Routes.FEED) {
|
if (item.route == Routes.FEED) {
|
||||||
feedViewModel.deactivateSearch()
|
feedViewModel.deactivateSearch()
|
||||||
|
feedViewModel.refreshTagsEnabled()
|
||||||
}
|
}
|
||||||
navController.navigate(item.route) {
|
navController.navigate(item.route) {
|
||||||
popUpTo(navController.graph.findStartDestination().id) {
|
popUpTo(navController.graph.findStartDestination().id) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue