Skip to content

Commit c598032

Browse files
committed
save last changed index.
1 parent 8736d2e commit c598032

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mobile/src/main/java/com/windscribe/mobile/ui/serverlist/ServerViewmodel.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ class ServerViewModelImpl(
9999
private val _searchListState = MutableStateFlow<ListState<ServerListItem>>(ListState.Loading)
100100
override val searchListState: StateFlow<ListState<ServerListItem>> = _searchListState
101101

102-
private val _selectedServerListType = MutableStateFlow(ServerListType.All)
102+
private val _selectedServerListType = MutableStateFlow(when (preferencesHelper.lastSelectedTabIndex) {
103+
0 -> ServerListType.All
104+
1 -> ServerListType.Fav
105+
2 -> ServerListType.Static
106+
3 -> ServerListType.Config
107+
else -> ServerListType.All
108+
})
103109
override val selectedServerListType: StateFlow<ServerListType> = _selectedServerListType
104110

105111

@@ -347,6 +353,12 @@ class ServerViewModelImpl(
347353
}
348354

349355
override fun setSelectedType(type: ServerListType) {
356+
preferencesHelper.saveLastSelectedServerTabIndex(when (type) {
357+
ServerListType.All -> 0
358+
ServerListType.Fav -> 1
359+
ServerListType.Static -> 2
360+
ServerListType.Config -> 3
361+
})
350362
_selectedServerListType.value = type
351363
}
352364

0 commit comments

Comments
 (0)