core: credit store receipts from a standard work queue

This commit is contained in:
spaced4ndy
2026-10-06 17:10:05 +04:00
parent 0d7efd0bc3
commit eee013dfcb
10 changed files with 210 additions and 228 deletions
@@ -109,8 +109,8 @@ final class BadgeStore: ObservableObject {
// kept for this run only: StoreKit lists no deferred purchase, and a declined one delivers nothing
// by invoice id, so a pending purchase shows only under the profile whose record it names
@Published private var waitingForApproval: Set<String> = []
// set when the first sweep has returned, which is after every transaction the store holds was handed
// to core - until then a purchase made while the app was not running is unknown
// set once presentUnfinished has read the store: until then, an Ask to Buy approved while the app was
// closed, or a purchase it died before handing over, are both unknown, so canBuy refuses to buy again
@Published private var reconciledOnce = false
// purchases the user started this run, by transaction: the store is not relied on to echo the invoice back
private var awaitedTransactions: Set<UInt64> = []
@@ -156,8 +156,8 @@ object BadgeStore {
private val buying = mutableStateOf(false)
// by invoice id, so a pending purchase shows only under the profile whose record it names
private val waitingForApproval = mutableStateOf<Set<String>>(emptySet())
// set when the first sweep has returned or failed, which is after every purchase the store holds was handed
// to core - until then a purchase made while the app was not running is unknown
// set once presentUnfinished has read the store, or failed to: until then, a slow payment completed while
// the app was closed, or a purchase it died before handing over, are both unknown, so canBuy refuses
private val reconciledOnce = mutableStateOf(false)
// purchases the user started this run, by token: the store is not relied on to echo the invoice back
private val awaitedTransactions = mutableSetOf<String>()