Skip to content
Snippets Groups Projects
Unverified Commit d5083dd5 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

fix: remember user account selected via navigation

parent 0718c182
Branches main
No related tags found
No related merge requests found
...@@ -120,6 +120,7 @@ fun MeteroidNavigation(navController: NavController, viewModel: NavigationViewMo ...@@ -120,6 +120,7 @@ fun MeteroidNavigation(navController: NavController, viewModel: NavigationViewMo
saveState = false saveState = false
} }
} }
viewModel.selectUser(entry.user.serverId, entry.user.userId)
} }
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
package de.chaosdorf.meteroid.ui.navigation package de.chaosdorf.meteroid.ui.navigation
import android.util.Log
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
...@@ -44,7 +45,8 @@ class NavigationViewModel @Inject constructor( ...@@ -44,7 +45,8 @@ class NavigationViewModel @Inject constructor(
userRepository: UserRepository, userRepository: UserRepository,
pinnedUserRepository: PinnedUserRepository, pinnedUserRepository: PinnedUserRepository,
syncManager: SyncManager, syncManager: SyncManager,
private val accountProvider: AccountProvider private val accountProvider: AccountProvider,
private val preferences: AccountPreferences
) : ViewModel() { ) : ViewModel() {
val expanded = MutableStateFlow(false) val expanded = MutableStateFlow(false)
val account = MutableStateFlow<AccountPreferences.State?>(null) val account = MutableStateFlow<AccountPreferences.State?>(null)
...@@ -117,4 +119,11 @@ class NavigationViewModel @Inject constructor( ...@@ -117,4 +119,11 @@ class NavigationViewModel @Inject constructor(
accountProvider.togglePin(serverId, userId) accountProvider.togglePin(serverId, userId)
} }
} }
fun selectUser(serverId: ServerId, userId: UserId) {
Log.i("UserListViewModel", "Updating AccountPreferences: $serverId $userId")
viewModelScope.launch {
preferences.setUser(serverId, userId)
}
}
} }
...@@ -64,7 +64,6 @@ class UserListViewModel @Inject constructor( ...@@ -64,7 +64,6 @@ class UserListViewModel @Inject constructor(
fun selectUser(serverId: ServerId, userId: UserId) { fun selectUser(serverId: ServerId, userId: UserId) {
Log.i("UserListViewModel", "Updating AccountPreferences: $serverId $userId") Log.i("UserListViewModel", "Updating AccountPreferences: $serverId $userId")
viewModelScope.launch { viewModelScope.launch {
preferences.setUser(serverId, userId) preferences.setUser(serverId, userId)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment