11package com.songlib.presentation.splash
22
33import android.content.Context
4- import androidx.lifecycle.ViewModel
5- import androidx.lifecycle.viewModelScope
4+ import androidx.lifecycle.*
65import com.songlib.core.helpers.NetworkUtils
7- import com.songlib.domain.repository.PrefsRepo
8- import com.songlib.domain.repository.SubsRepo
9- import com.songlib.presentation.navigation.Routes
6+ import com.songlib.domain.repository.*
107import dagger.hilt.android.lifecycle.HiltViewModel
11- import kotlinx.coroutines.flow.MutableStateFlow
12- import kotlinx.coroutines.flow.StateFlow
13- import kotlinx.coroutines.flow.asStateFlow
8+ import kotlinx.coroutines.flow.*
149import kotlinx.coroutines.launch
1510import javax.inject.Inject
1611
@@ -30,9 +25,9 @@ class SplashViewModel @Inject constructor(
3025 } else {
3126 checkSubscriptionAndTime(false )
3227 }
33- determineNextRoute()
28+ _isLoading .value = false
3429 } catch (e: Exception ) {
35- determineNextRoute()
30+ _isLoading .value = false
3631 } finally {
3732 _isLoading .value = false
3833 }
@@ -47,13 +42,4 @@ class SplashViewModel @Inject constructor(
4742 }
4843 prefsRepo.updateAppOpenTime()
4944 }
50-
51- private fun determineNextRoute () {
52- _nextRoute .value = when {
53- prefsRepo.selectAfresh -> Routes .STEP_1
54- prefsRepo.isDataSelected && prefsRepo.isDataLoaded -> Routes .HOME
55- prefsRepo.isDataSelected && ! prefsRepo.isDataLoaded -> Routes .STEP_2
56- else -> Routes .HOME
57- }
58- }
5945}
0 commit comments