Skip to content

Commit ad5c349

Browse files
committed
chore(flipcash): allow access key deeplinks to route when unpaid
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent eb2731a commit ad5c349

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/router/LoginRouter.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ class LoginRouter(
5252
.launchIn(this)
5353
}
5454

55+
LaunchedEffect(vm) {
56+
vm.eventFlow
57+
.filterIsInstance<LoginViewModel.Event.LoggedInRequiresPayment>()
58+
.onEach { delay(1.333.seconds) }
59+
.onEach {
60+
navigator.push(
61+
items = listOf(
62+
ScreenRegistry.get(NavScreenProvider.CreateAccount.AccessKey),
63+
ScreenRegistry.get(
64+
NavScreenProvider.CreateAccount.Purchase(true)
65+
)
66+
)
67+
)
68+
}
69+
.launchIn(this)
70+
}
71+
5572
LaunchedEffect(seed) {
5673
if (seed != null) {
5774
vm.dispatchEvent(LoginViewModel.Event.LogIn(seed, fromDeeplink))

apps/flipcash/features/login/src/main/kotlin/com/flipcash/app/login/router/LoginViewModel.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class LoginViewModel @Inject constructor(
4444
data class LogIn(val seed: String, val fromDeeplink: Boolean = false) : Event
4545
data class FacilitateLogin(val entropyB64: String) : Event
4646
data object LoggedInSuccessfully : Event
47+
data object LoggedInRequiresPayment : Event
4748
data object LogInFailed : Event
4849
data object OnAccountCreated : Event
4950
data object CreateFailed : Event
@@ -131,7 +132,7 @@ class LoginViewModel @Inject constructor(
131132
if (it.isRegistered) {
132133
dispatchEvent(Event.LoggedInSuccessfully)
133134
} else {
134-
dispatchEvent(Event.LogInFailed)
135+
dispatchEvent(Event.LoggedInRequiresPayment)
135136
}
136137
}.onFailure {
137138
dispatchEvent(Event.LogInFailed)
@@ -187,6 +188,15 @@ class LoginViewModel @Inject constructor(
187188
)
188189
}
189190

191+
is Event.LoggedInRequiresPayment -> { state ->
192+
state.copy(
193+
loggingIn = LoadingSuccessState(
194+
loading = false,
195+
success = true
196+
)
197+
)
198+
}
199+
190200
is Event.LogInFailed -> { state ->
191201
state.copy(
192202
loggingIn = LoadingSuccessState(

0 commit comments

Comments
 (0)