diff --git a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift index 05cfdd76..8ffae2ec 100644 --- a/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift +++ b/TalerWallet1/Views/Actions/Banking/DepositAmountAction.swift @@ -23,6 +23,24 @@ struct DepositAmountAction: View { @EnvironmentObject private var model: WalletModel @State private var balanceIndex = 0 + /// Bumped on every `.BalanceChange`, and folded into the task id below. + /// + /// The maximum this screen shows is read once per balance selection: + /// the task's id is `balanceIndex + 1000 * currencyTicker`, and + /// `currencyTicker` is incremented only by `Controller.setInfo` -- + /// "updates whenever a new currency is added" -- so a balance change + /// moved nothing. Measured 2026-11-09: 19.6 s after a withdrawal + /// reached `Done` with KUDOS 25 spendable, the screen still read + /// "Available: KUDOS 0.00" and the KUDOS 5.00, 10.00 and + /// 25.00 shortcuts were all still disabled, because + /// `ShortcutButton.isDisabled` compares against that same stale value. + /// Issue 11982. + /// + /// wallet-core does announce it (`WalletCore.swift` posts + /// `.BalanceChange`); the only subscriber was `WalletMain`, which + /// reloads the list behind this sheet while the sheet's own number + /// stayed put. + @State private var balanceReload = 0 @State private var balance: Balance? = nil // nil only when balances == [] @State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN) @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used @@ -173,7 +191,9 @@ struct DepositAmountAction: View { setVoice(to: nil) await viewDidLoad() } - .task(id: balanceIndex + (1000 * controller.currencyTicker)) { await newBalance() } + .onNotification(.BalanceChange) { _ in balanceReload += 1 } + .task(id: balanceIndex + (1000 * controller.currencyTicker) + + (1_000_000 * balanceReload)) { await newBalance() } if #available(iOS 16.4, *) { scrollView.toolbar(.hidden, for: .tabBar) diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift index 6a7fba51..41a18bd3 100755 --- a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift +++ b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift @@ -26,6 +26,24 @@ struct SendAmountV: View { @StateObject private var cash: OIMcash @State private var balanceIndex = 0 + /// Bumped on every `.BalanceChange`, and folded into the task id below. + /// + /// The maximum this screen shows is read once per balance selection: + /// the task's id is `balanceIndex + 1000 * currencyTicker`, and + /// `currencyTicker` is incremented only by `Controller.setInfo` -- + /// "updates whenever a new currency is added" -- so a balance change + /// moved nothing. Measured 2026-11-09: 19.6 s after a withdrawal + /// reached `Done` with KUDOS 25 spendable, the screen still read + /// "Available for transfer: KUDOS 0.00" and the KUDOS 5.00, 10.00 and + /// 25.00 shortcuts were all still disabled, because + /// `ShortcutButton.isDisabled` compares against that same stale value. + /// Issue 11982. + /// + /// wallet-core does announce it (`WalletCore.swift` posts + /// `.BalanceChange`); the only subscriber was `WalletMain`, which + /// reloads the list behind this sheet while the sheet's own number + /// stayed put. + @State private var balanceReload = 0 @State private var balance: Balance? = nil // nil only when balances == [] @State private var currencyInfo: CurrencyInfo = CurrencyInfo.zero(UNKNOWN) @State private var amountToTransfer = Amount.zero(currency: EMPTYSTRING) // Update currency when used @@ -113,6 +131,7 @@ struct SendAmountV: View { let count = controller.balances.count let _ = symLog.log("count = \(count)") let taskID = balanceIndex + (1000 * controller.currencyTicker) + + (1_000_000 * balanceReload) let scrollView = ScrollView { if count > 1 { ScopePicker(stack: stack.push(), @@ -144,6 +163,7 @@ struct SendAmountV: View { .frame(maxWidth: .infinity, alignment: .leading) .background(FullBackground()) .task { await viewDidLoad() } + .onNotification(.BalanceChange) { _ in balanceReload += 1 } .task(id: taskID) { let avail = amountAvailable await newBalance()