From bf240c4203c9745aae9eb3139be442256bbfebd1 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 8 Aug 2024 13:14:29 +0200 Subject: [PATCH] fix login via login screen --- .../main/java/eu/m724/vastapp/activity/login/LoginViewModel.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/eu/m724/vastapp/activity/login/LoginViewModel.kt b/app/src/main/java/eu/m724/vastapp/activity/login/LoginViewModel.kt index f05016b..6a9ce05 100644 --- a/app/src/main/java/eu/m724/vastapp/activity/login/LoginViewModel.kt +++ b/app/src/main/java/eu/m724/vastapp/activity/login/LoginViewModel.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import eu.m724.vastapp.BuildConfig import eu.m724.vastapp.VastApplication +import eu.m724.vastapp.vastai.Account import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -34,12 +35,14 @@ class LoginViewModel( } fun tryLogin() { + application.vastApi.setApiKey(apiKey.value) val userDeferred = application.vastApi.getUser() viewModelScope.launch { try { val user = userDeferred.await() application.submitKey(apiKey.value) // TODO toggle for this + application.account = Account(user) _uiState.update { LoginUiState.Success(user) } } catch (e: Exception) { _uiState.update { LoginUiState.Idle }