Skip to content

Commit 95d80e3

Browse files
committed
fix(authcheck): ensure can logout after deeplink launch
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 420c9d8 commit 95d80e3

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

app/src/main/java/com/getcode/view/components/AuthCheck.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,22 @@ fun AuthCheck(
6060
// Allow the seed input screen to complete and avoid
6161
// premature navigation
6262
if (currentRoute is AccessKeyLoginScreen) {
63-
Timber.tag(AUTH_NAV).d("No navigation within seed input")
63+
log("No navigation within seed input")
6464
return@LaunchedEffect
6565
}
6666
if (currentRoute is LoginGraph) {
67-
Timber.tag(AUTH_NAV).d("No navigation within account creation and onboarding")
67+
log("No navigation within account creation and onboarding")
6868
} else {
6969
if (authenticated) {
70-
Timber.tag(AUTH_NAV).d("Navigating to home")
70+
log("Navigating to home")
7171
onNavigate(listOf(HomeScreen()), false)
7272
} else {
73-
Timber.tag(AUTH_NAV).d("Navigating to login")
73+
log("Navigating to login")
7474
onNavigate(listOf(LoginScreen()), false)
7575
}
7676
}
77+
} else {
78+
deeplinkRouted = false
7779
}
7880
}
7981
}
@@ -99,7 +101,7 @@ fun AuthCheck(
99101
if (type is DeeplinkHandler.Type.Login) {
100102
if (auth.isAuthenticated == true) {
101103
val entropy = (screens.first() as? LoginScreen)?.seed
102-
Timber.tag(AUTH_NAV).d("showing logout confirm")
104+
log("showing logout confirm")
103105
if (entropy != null) {
104106
deeplinkRouted = true
105107
context.getActivity()?.intent = null
@@ -109,7 +111,7 @@ fun AuthCheck(
109111
entropyB64 = entropy,
110112
onSwitchAccounts = {
111113
scope.launch {
112-
delay(300)
114+
delay(300) // wait for dismiss
113115
onSwitchAccounts(it)
114116
deeplinkRouted = false
115117
}
@@ -126,7 +128,7 @@ fun AuthCheck(
126128
}
127129
.onEach { screens ->
128130
deeplinkRouted = true
129-
Timber.tag(AUTH_NAV).d("navigated")
131+
log("navigated")
130132
onNavigate(screens, true)
131133
deeplinkHandler.debounceIntent = null
132134
context.getActivity()?.intent = null
@@ -135,6 +137,8 @@ fun AuthCheck(
135137
}
136138
}
137139

140+
private fun log(message: String) = Timber.tag(AUTH_NAV).d(message)
141+
138142
private fun showLogoutMessage(
139143
context: Context,
140144
entropyB64: String,
@@ -144,7 +148,6 @@ private fun showLogoutMessage(
144148
BottomBarManager.showMessage(
145149
BottomBarManager.BottomBarMessage(
146150
title = context.getString(R.string.subtitle_logoutAndLoginConfirmation),
147-
subtitle = "",
148151
positiveText = context.getString(R.string.action_logIn),
149152
negativeText = context.getString(R.string.action_cancel),
150153
isDismissible = false,

app/src/main/java/com/getcode/view/main/account/AccountHome.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import com.getcode.theme.CodeTheme
4949
import com.getcode.theme.White10
5050
import com.getcode.util.getActivity
5151
import com.getcode.util.rememberedClickable
52+
import kotlinx.coroutines.delay
5253
import kotlinx.coroutines.launch
5354

5455
@Composable
@@ -80,8 +81,11 @@ fun AccountHome(
8081
positiveText = context.getString(R.string.action_logout),
8182
negativeText = context.getString(R.string.action_cancel),
8283
onPositive = {
83-
context.getActivity()?.let {
84-
viewModel.logout(it)
84+
composeScope.launch {
85+
delay(150) // wait for dismiss
86+
context.getActivity()?.let {
87+
viewModel.logout(it)
88+
}
8589
}
8690
}
8791
)

0 commit comments

Comments
 (0)