nwc: turn pending zap orange when we have a NWC success

Orange means payment successful now, not just presence of zap

This introduces a paid pending state, which shows up as an orange timer
thing in the zaps view. This can be useful if the zap is never sent. We
don't want the user to think the payment didn't go through.
This commit is contained in:
William Casarin
2023-05-13 23:28:07 -07:00
parent 03691d0369
commit 69fc6694f1
6 changed files with 68 additions and 19 deletions

View File

@@ -188,7 +188,7 @@ func nwc_pay(url: WalletConnectURL, pool: RelayPool, post: PostBox, invoice: Str
}
func nwc_success(zapcache: Zaps, resp: FullWalletResponse) {
func nwc_success(zapcache: Zaps, evcache: EventCache, resp: FullWalletResponse) {
// find the pending zap and mark it as pending-confirmed
for kv in zapcache.our_zaps {
let zaps = kv.value
@@ -202,7 +202,10 @@ func nwc_success(zapcache: Zaps, resp: FullWalletResponse) {
continue
}
nwc_state.state = .confirmed
if nwc_state.update_state(state: .confirmed) {
// notify the zaps model of an update so it can mark them as paid
evcache.get_cache_data(pzap.target.id).zaps_model.objectWillChange.send()
}
return
}
}