ios, android: keep the badge link screen open while it redeems, and redeem once

This commit is contained in:
spaced4ndy
2026-09-25 19:12:23 +04:00
parent d167013e84
commit 8fd510aa82
2 changed files with 8 additions and 1 deletions
@@ -327,9 +327,13 @@ struct BadgesRedeemLinkView: View {
.padding(.bottom, 20)
.frame(maxHeight: .infinity)
.navigationBarTitleDisplayMode(.inline)
// the outcome closes what is on screen, which after a close here would be some other screen
.interactiveDismissDisabled(true)
}
private func redeemFromLink() {
// a second tap before the screen changes must not send the code again
guard step == .confirming else { return }
guard let user = chatModel.currentUser else { return dismissAllSheets() }
step = .issuing
Task {
@@ -276,6 +276,8 @@ fun BadgesRedeemLinkView(rhId: Long?, code: String, close: () -> Unit) {
val step = remember { mutableStateOf(BadgeLinkStep.Confirming) }
fun redeemFromLink() {
// a second tap before the screen changes must not send the code again
if (step.value != BadgeLinkStep.Confirming) return
val user = chatModel.currentUser.value ?: return close()
step.value = BadgeLinkStep.Issuing
withBGApi {
@@ -295,7 +297,8 @@ fun BadgesRedeemLinkView(rhId: Long?, code: String, close: () -> Unit) {
when (step.value) {
BadgeLinkStep.Confirming -> ModalView(close) { Confirming(onConfirm = ::redeemFromLink, onCancel = close) }
BadgeLinkStep.Issuing -> ModalView(close) { BeingIssued() }
// the outcome closes what is on screen, which after a close here would be some other screen
BadgeLinkStep.Issuing -> ModalView(close, enableClose = false) { BeingIssued() }
BadgeLinkStep.Redeemed -> BadgesView(ModalManager.end, close)
}
}