mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 15:50:16 +02:00
Always initialize server/user view models
This commit is contained in:
parent
c5a5345f6c
commit
b7dfb2ca5f
4 changed files with 7 additions and 10 deletions
|
|
@ -53,6 +53,7 @@ fun SwitchServerContent(
|
|||
var showAddServer by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.init()
|
||||
viewModel.discoverServers()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,6 @@ class SwitchServerViewModel
|
|||
addServerState.value = LoadingState.Pending
|
||||
}
|
||||
|
||||
init {
|
||||
init()
|
||||
}
|
||||
|
||||
fun init() {
|
||||
viewModelScope.launchIO {
|
||||
withContext(Dispatchers.Main) {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ fun SwitchUserContent(
|
|||
),
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.init()
|
||||
}
|
||||
|
||||
// val currentServer by viewModel.serverRepository.currentServer.observeAsState()
|
||||
val currentUser by viewModel.serverRepository.currentUser.observeAsState()
|
||||
|
|
|
|||
|
|
@ -48,12 +48,6 @@ class SwitchUserViewModel
|
|||
fun create(server: JellyfinServer): SwitchUserViewModel
|
||||
}
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.Main + ExceptionHandler()) {
|
||||
serverRepository.switchServerOrUser()
|
||||
}
|
||||
}
|
||||
|
||||
val serverQuickConnect = MutableLiveData<Boolean>(false)
|
||||
|
||||
val users = MutableLiveData<List<JellyfinUser>>(listOf())
|
||||
|
|
@ -78,6 +72,9 @@ class SwitchUserViewModel
|
|||
}
|
||||
|
||||
fun init() {
|
||||
viewModelScope.launch(Dispatchers.Main + ExceptionHandler()) {
|
||||
serverRepository.switchServerOrUser()
|
||||
}
|
||||
quickConnectJob?.cancel()
|
||||
viewModelScope.launchIO {
|
||||
users.setValueOnMain(listOf())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue