From eaa149a0e92dac8e889296d873fd333b966f309d Mon Sep 17 00:00:00 2001 From: Jeremiah K <17190268+jeremiah-k@users.noreply.github.com> Date: Sat, 14 Jun 2025 13:22:16 -0500 Subject: [PATCH] Persist node sort preference across app restarts (#2115) --- app/src/main/java/com/geeksville/mesh/model/UIState.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/model/UIState.kt b/app/src/main/java/com/geeksville/mesh/model/UIState.kt index 2a73b11cb..f3e216e7d 100644 --- a/app/src/main/java/com/geeksville/mesh/model/UIState.kt +++ b/app/src/main/java/com/geeksville/mesh/model/UIState.kt @@ -272,7 +272,11 @@ class UIViewModel @Inject constructor( .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList()) private val nodeFilterText = MutableStateFlow("") - private val nodeSortOption = MutableStateFlow(NodeSortOption.VIA_FAVORITE) + private val nodeSortOption = MutableStateFlow( + NodeSortOption.entries.getOrElse( + preferences.getInt("node-sort-option", NodeSortOption.VIA_FAVORITE.ordinal) + ) { NodeSortOption.VIA_FAVORITE } + ) private val includeUnknown = MutableStateFlow(preferences.getBoolean("include-unknown", false)) private val showDetails = MutableStateFlow(preferences.getBoolean("show-details", false)) private val onlyOnline = MutableStateFlow(preferences.getBoolean("only-online", false)) @@ -285,6 +289,7 @@ class UIViewModel @Inject constructor( fun setSortOption(sort: NodeSortOption) { nodeSortOption.value = sort + preferences.edit { putInt("node-sort-option", sort.ordinal) } } fun toggleShowDetails() {