From f2f38ad35eaffa7ceb0f9b016a60e2aa7729b333 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 25 Nov 2026 13:47:54 +0100 Subject: [PATCH 1/2] fix: let confirm take a swipe after a failed send Verified: none (unit suite running on the simulator) --- Bitkit/Components/SwipeButton.swift | 7 ++++++ .../Views/Wallets/Send/LnurlPayConfirm.swift | 3 ++- .../Wallets/Send/SendConfirmationView.swift | 9 +++++++- BitkitTests/SendConfirmationSwipeTests.swift | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Bitkit/Components/SwipeButton.swift b/Bitkit/Components/SwipeButton.swift index cb6ee2826..9c33c6701 100644 --- a/Bitkit/Components/SwipeButton.swift +++ b/Bitkit/Components/SwipeButton.swift @@ -11,6 +11,8 @@ struct SwipeButton: View { var isComplete = false /// Optional binding for swipe progress (0...1), e.g. to drive animations in the parent. var swipeProgress: Binding? + /// Each change puts a submitted knob back at the start, for a swipe whose screen moved on without the swipe throwing. + var resetCount = 0 let onComplete: () async throws -> Void @State private var offset: CGFloat = 0 @@ -125,6 +127,11 @@ struct SwipeButton: View { } .frame(maxWidth: .infinity) .frame(height: buttonHeight) + .onChange(of: resetCount) { + if isSubmitting { + reset() + } + } } private func reset() { diff --git a/Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift b/Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift index c043635a8..b1c3fe40d 100644 --- a/Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift +++ b/Bitkit/Views/Wallets/Send/LnurlPayConfirm.swift @@ -211,7 +211,8 @@ struct LnurlPayConfirm: View { accentColor: .greenAccent, isDisabled: isSparkUpdateQuoting, isLoading: hasStartedAutomaticPayment || isSubmittingPayment, - isSubmitted: hasStartedAutomaticPayment + isSubmitted: hasStartedAutomaticPayment, + resetCount: swipeLock.idleReturns ) { swipeLock.begin() defer { swipeLock.end() } diff --git a/Bitkit/Views/Wallets/Send/SendConfirmationView.swift b/Bitkit/Views/Wallets/Send/SendConfirmationView.swift index 4534caf5a..aafb8fa7f 100644 --- a/Bitkit/Views/Wallets/Send/SendConfirmationView.swift +++ b/Bitkit/Views/Wallets/Send/SendConfirmationView.swift @@ -525,7 +525,8 @@ struct SendConfirmationView: View { isSubmittingPayment: isSubmittingPayment ), isSubmitted: hasStartedAutomaticPayment, - swipeProgress: $swipeProgress + swipeProgress: $swipeProgress, + resetCount: swipeLock.idleReturns ) { swipeLock.begin() defer { swipeLock.end() } @@ -3183,6 +3184,9 @@ final class ConfirmSwipeLock { private(set) var runs = 0 private(set) var isVisible = false private(set) var isSubmittingPayment = false + /// Counts the returns to Confirm with nothing running, such as Back or Try again after a failed payment, which leave + /// the swipe as it ended. + private(set) var idleReturns = 0 @ObservationIgnored var onLockChange: (Bool) -> Void = { _ in } @ObservationIgnored private var isHolding = false @@ -3202,6 +3206,9 @@ final class ConfirmSwipeLock { func setVisible(_ isVisible: Bool) { self.isVisible = isVisible + if isVisible, runs == 0, !isSubmittingPayment { + idleReturns += 1 + } report() } diff --git a/BitkitTests/SendConfirmationSwipeTests.swift b/BitkitTests/SendConfirmationSwipeTests.swift index ac12f6eb5..aa1fb616b 100644 --- a/BitkitTests/SendConfirmationSwipeTests.swift +++ b/BitkitTests/SendConfirmationSwipeTests.swift @@ -35,6 +35,29 @@ final class SendConfirmationSwipeTests: XCTestCase { XCTAssertEqual(SwipeBackState.confirmSwipeHolds, holdsBefore, "Every hold is let go") } + @MainActor + func testReturningToConfirmWithNothingRunningResetsTheSwipe() { + let lock = ConfirmSwipeLock() + lock.setVisible(true) + let shown = lock.idleReturns + + lock.begin() + lock.setVisible(false) + lock.setVisible(true) + XCTAssertEqual(lock.idleReturns, shown, "A swipe still running keeps its knob") + lock.setVisible(false) + lock.end() + lock.setSubmittingPayment(true) + lock.setVisible(true) + XCTAssertEqual(lock.idleReturns, shown, "A payment still running keeps its knob") + lock.setVisible(false) + lock.setSubmittingPayment(false) + + lock.setVisible(true) + XCTAssertEqual(lock.idleReturns, shown + 1, "Try again or Back after a failed payment takes a new swipe") + lock.setVisible(false) + } + @MainActor func testALeavingConfirmKeepsTheNextConfirmsHold() { let holdsBefore = SwipeBackState.confirmSwipeHolds From 48b535e27c866b897c6541ce948f5caa8d982a27 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Wed, 25 Nov 2026 14:13:31 +0100 Subject: [PATCH 2/2] chore: add changelog fragment Verified: none (changelog text only) --- changelog.d/next/1430.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/next/1430.fixed.md diff --git a/changelog.d/next/1430.fixed.md b/changelog.d/next/1430.fixed.md new file mode 100644 index 000000000..76e8e3d18 --- /dev/null +++ b/changelog.d/next/1430.fixed.md @@ -0,0 +1 @@ +Retrying a failed payment from the send confirmation screen takes a new swipe instead of leaving the slider spinning.