From 6b1f491bac953f5f9834ea7495d9b60763035092 Mon Sep 17 00:00:00 2001 From: romchornyi Date: Mon, 9 Nov 2026 19:08:28 +0200 Subject: [PATCH] fix(dashpay): check a replacement invitation once, not twice When an invitation is hidden while its check runs and another one takes its place, two callers wait for the stale check: the store's change and the stale check's own end. If one of them checked the replacement and finished before the other woke, the other found no running check and asked the network again. runValidation now returns the fresh verdict for the same invitation instead. Co-Authored-By: Claude Opus 5.5 --- .../UI/DashPay/Invitations/PendingInvitationViewModel.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DashWallet/Sources/UI/DashPay/Invitations/PendingInvitationViewModel.swift b/DashWallet/Sources/UI/DashPay/Invitations/PendingInvitationViewModel.swift index a479d07243..e6ecbbd63c 100644 --- a/DashWallet/Sources/UI/DashPay/Invitations/PendingInvitationViewModel.swift +++ b/DashWallet/Sources/UI/DashPay/Invitations/PendingInvitationViewModel.swift @@ -315,6 +315,12 @@ final class PendingInvitationViewModel: ObservableObject { if let validationTask, validationFor == invitation { return await validationTask.value } + // Another caller that waited for the same stale check may have + // checked this invitation already and finished: its verdict stands. + if let lastVerdict, lastVerdict.invitation == invitation, + Date().timeIntervalSince(lastVerdict.at) < Self.validationLifetime { + return lastVerdict.validation + } cardState = .verifying let token = UUID() let validate = self.validate