Remove the book update from the splashscreen.
This commit is contained in:
parent
537cf214a9
commit
58ebd970f2
1 changed files with 5 additions and 25 deletions
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue