@@ -20,6 +20,7 @@ import com.getcode.navigation.screens.HomeScreen
2020import com.getcode.navigation.screens.LoginGraph
2121import com.getcode.navigation.screens.LoginScreen
2222import com.getcode.util.DeeplinkHandler
23+ import com.getcode.util.DeeplinkResult
2324import com.getcode.util.getActivity
2425import kotlinx.coroutines.CoroutineScope
2526import kotlinx.coroutines.delay
@@ -38,7 +39,7 @@ import kotlinx.coroutines.launch
3839import timber.log.Timber
3940
4041private const val APP_STARTUP_TAG = " app-startup"
41- private typealias DeeplinkFlowState = Pair <Pair < DeeplinkHandler . Type , List < Screen >> , SessionManager .SessionState >
42+ private typealias DeeplinkFlowState = Pair <DeeplinkResult , SessionManager .SessionState >
4243
4344@Composable
4445fun AuthCheck (
@@ -92,7 +93,12 @@ fun AuthCheck(
9293 .filter { (result, authState) ->
9394 startupLog(" checking auth state=${authState.isAuthenticated} " )
9495 // wait for authentication
95- return @filter result != null && authState.isAuthenticated == true
96+ if (result == null ) return @filter false
97+ if ( authState.isAuthenticated == null ) {
98+ startupLog(" awaiting auth state confirmation" )
99+ return @filter false
100+ }
101+ return @filter true
96102 }.mapNotNull { (result, state) ->
97103 result ? : return @mapNotNull null
98104 result to state
@@ -128,22 +134,23 @@ private fun Flow<DeeplinkFlowState>.mapSeedToHome(): Flow<DeeplinkFlowState> =
128134 startupLog(" checking type" )
129135 val (type, screens) = data
130136 if (type is DeeplinkHandler .Type .Login && auth.isAuthenticated == true ) {
137+ startupLog(" mapping entropy to home screen" )
131138 // send the user to home screen
132139 val entropy = (screens.first() as ? LoginScreen )?.seed
133- val updatedData = type to listOf (HomeScreen (seed = entropy))
140+ val updatedData = data.copy(stack = listOf (HomeScreen (seed = entropy) ))
134141 updatedData to auth
135142 } else {
136143 data to auth
137144 }
138145 }
139146
140147
141- private fun Flow<Pair<DeeplinkHandler. Type , List<Screen>> >.showLogoutConfirmationIfNeeded (
148+ private fun Flow<DeeplinkResult >.showLogoutConfirmationIfNeeded (
142149 context : Context ,
143150 scope : CoroutineScope ,
144151 onSwitchAccounts : (String ) -> Unit ,
145152 onCancel : () -> Unit
146- ): Flow <Pair < DeeplinkHandler . Type , List < Screen >> > = onEach { (type, screens) ->
153+ ): Flow <DeeplinkResult > = onEach { (type, screens) ->
147154 if (type is DeeplinkHandler .Type .Login ) {
148155 val entropy = (screens.first() as ? HomeScreen )?.seed
149156 startupLog(" showing logout confirm" )
0 commit comments