From 58ebd970f24cb2c187fa8c81268e379e848ed6d3 Mon Sep 17 00:00:00 2001 From: Thomas Andres Gomez Date: Fri, 21 Oct 2022 15:55:29 +0200 Subject: [PATCH] Remove the book update from the splashscreen. --- .../ui/screen/launch/LauncherViewModel.kt | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/pixelized/biblib/ui/screen/launch/LauncherViewModel.kt b/app/src/main/java/com/pixelized/biblib/ui/screen/launch/LauncherViewModel.kt index d3656c1..858289e 100644 --- a/app/src/main/java/com/pixelized/biblib/ui/screen/launch/LauncherViewModel.kt +++ b/app/src/main/java/com/pixelized/biblib/ui/screen/launch/LauncherViewModel.kt @@ -7,15 +7,11 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.pixelized.biblib.network.client.IBibLibClient import com.pixelized.biblib.network.data.query.AuthLoginQuery -import com.pixelized.biblib.repository.apiCache.IAPICacheRepository -import com.pixelized.biblib.repository.book.IBookRepository -import com.pixelized.biblib.repository.book.updateBooks import com.pixelized.biblib.repository.credential.ICredentialRepository import com.pixelized.biblib.repository.googleSignIn.IGoogleSingInRepository import com.pixelized.biblib.ui.navigation.Screen import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import javax.inject.Inject @@ -24,8 +20,6 @@ class LauncherViewModel @Inject constructor( private val credentialRepository: ICredentialRepository, private val googleSignIn: IGoogleSingInRepository, private val client: IBibLibClient, - private val bookRepository: IBookRepository, - private val apiCache: IAPICacheRepository, ) : ViewModel() { var isLoadingDone by mutableStateOf(false) @@ -35,20 +29,13 @@ class LauncherViewModel @Inject constructor( private set init { - viewModelScope.launch(Dispatchers.IO) { + viewModelScope.launch { // Try to Authenticate - if (autoLoginWithGoogle() || autologinWithCredential()) { - startDestination = try { - // Update book - updateBooks() - // Change the start destination - Screen.Home - } catch (exception: Exception) { - // Force the authentication process. - Screen.Authentication - } + startDestination = if (autoLoginWithGoogle() || autologinWithCredential()) { + Screen.Home + } else { + Screen.Authentication } - delay(1000) // Update loading state. isLoadingDone = true } @@ -102,11 +89,4 @@ class LauncherViewModel @Inject constructor( // endregion ////////////////////////////////////// - // region: Books update - - private suspend fun updateBooks() = updateBooks( - client = client, - cache = apiCache, - repository = bookRepository, - ) } \ No newline at end of file