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 }