use payments/sse on the core wallet UI.

still fallback to the invoice polling (now with a 5 seconds interval
because less than that is too annoying).

this fixes issues with /lnurlwallet invoices not getting paid in time,
so we update the UI automatically when they do get paid.

(see https://t.me/lnbits/7069)
This commit is contained in:
fiatjaf
2020-10-15 00:18:57 -03:00
parent f02ec67f35
commit be7d36214a
4 changed files with 59 additions and 33 deletions
+13
View File
@@ -63,6 +63,19 @@ window.LNbits = {
)
}
},
events: {
onInvoicePaid: function (wallet, cb) {
if (!this.pis) {
this.pis = new EventSource(
'/api/v1/payments/sse?api-key=' + wallet.inkey
)
}
this.pis.addEventListener('payment-received', ev =>
cb(JSON.parse(ev.data))
)
}
},
href: {
createWallet: function (walletName, userId) {
window.location.href =