Skip to content

Commit b091d1e

Browse files
authored
Merge pull request #106 from code-payments/fix/phone-link-hint-vis
fix(phone/link): ensure google hint only pops once per flow
2 parents 55f4903 + 04c88d5 commit b091d1e

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/src/main/java/com/getcode/view/login/PhoneVerify.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ internal fun PhoneVerify(
152152
contract = ActivityResultContracts.StartIntentSenderForResult()
153153
) {
154154
if (it.resultCode != Activity.RESULT_OK) {
155+
viewModel.dismissedHint()
155156
return@rememberLauncherForActivityResult
156157
}
157158

@@ -161,13 +162,13 @@ internal fun PhoneVerify(
161162
viewModel.setPhoneFromHint(phoneNum)
162163
}
163164

164-
LaunchedEffect(phoneNumberHintLauncher) {
165+
LaunchedEffect(dataState.hasDismissedHint) {
165166
val request = GetPhoneNumberHintIntentRequest
166167
.builder()
167168
.build()
168169

169170
val isSettled = navigator.lastItem == navigator.lastModalItem || arguments.isNewAccount
170-
if (isSettled && dataState.phoneNumberFormatted.isEmpty()) {
171+
if (isSettled && dataState.phoneNumberFormatted.isEmpty() && !dataState.hasDismissedHint) {
171172
Identity.getSignInClient(context)
172173
.getPhoneNumberHintIntent(request)
173174
.addOnSuccessListener {

app/src/main/java/com/getcode/view/login/PhoneVerifyViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ data class PhoneVerifyUiModel(
5151
val entropyB64: String? = null,
5252
val isPhoneLinking: Boolean = false,
5353
val isNewAccount: Boolean = false,
54+
val hasDismissedHint: Boolean = false,
5455
)
5556

5657
@HiltViewModel
@@ -87,6 +88,8 @@ class PhoneVerifyViewModel @Inject constructor(
8788
uiFlow.update { it.copy(isNewAccount = isNewAccount) }
8889
}
8990

91+
fun dismissedHint() = uiFlow.update { it.copy(hasDismissedHint = true) }
92+
9093
fun setCountryCode(countryLocale: PhoneUtils.CountryLocale) {
9194
uiFlow.update { it.copy(countryLocale = countryLocale) }
9295
}

0 commit comments

Comments
 (0)