Skip to content

Commit

Permalink
feat: persist node filters to SharedPreferences
Browse files Browse the repository at this point in the history
closes #1392
  • Loading branch information
andrekir committed Nov 10, 2024
1 parent 2d2d949 commit e729402
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/com/geeksville/mesh/model/UIState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,21 @@ class UIViewModel @Inject constructor(

private val nodeFilterText = MutableStateFlow("")
private val nodeSortOption = MutableStateFlow(NodeSortOption.LAST_HEARD)
private val includeUnknown = MutableStateFlow(false)
private val showDetails = MutableStateFlow(false)
private val includeUnknown = MutableStateFlow(preferences.getBoolean("include-unknown", false))
private val showDetails = MutableStateFlow(preferences.getBoolean("show-details", false))

fun setSortOption(sort: NodeSortOption) {
nodeSortOption.value = sort
}

fun toggleShowDetails() {
showDetails.value = !showDetails.value
preferences.edit { putBoolean("show-details", showDetails.value) }
}

fun toggleIncludeUnknown() {
includeUnknown.value = !includeUnknown.value
preferences.edit { putBoolean("include-unknown", includeUnknown.value) }
}

val nodesUiState: StateFlow<NodesUiState> = combine(
Expand Down

0 comments on commit e729402

Please sign in to comment.