Changed back to polling

Once a stable listener alternative is production ready it can be added back
This commit is contained in:
Ben Arc 2021-08-16 07:15:59 +01:00
parent 7bdbe08732
commit 36af425c1b
2 changed files with 26 additions and 37 deletions

View File

@ -103,7 +103,9 @@
name: '', name: '',
email: '', email: '',
text: '' text: ''
} },
dismissMsg: null,
paymentChecker: null
}, },
receive: { receive: {
show: false, show: false,
@ -143,39 +145,9 @@
this.formDialog.data.email = '' this.formDialog.data.email = ''
this.formDialog.data.text = '' this.formDialog.data.text = ''
}, },
closeReceiveDialog: function () {
var checker = this.startPaymentNotifier
dismissMsg()
setTimeout(function () {}, 10000)
},
startPaymentNotifier() {
this.cancelListener()
this.cancelListener = LNbits.events.onInvoicePaid(
this.wallet,
payment => {
this.receive = {
show: false,
status: 'complete',
paymentReq: null
}
dismissMsg()
this.formDialog.data.name = ''
this.formDialog.data.email = ''
this.formDialog.data.text = ''
this.$q.notify({
type: 'positive',
message: 'Sent, thank you!',
icon: 'thumb_up'
})
}
)
},
Invoice: function () { Invoice: function () {
var self = this var self = this
var dialog = this.formDialog
axios axios
.post('/lnticket/api/v1/tickets/{{ form_id }}', { .post('/lnticket/api/v1/tickets/{{ form_id }}', {
form: '{{ form_id }}', form: '{{ form_id }}',
@ -188,16 +160,34 @@
self.paymentReq = response.data.payment_request self.paymentReq = response.data.payment_request
self.paymentCheck = response.data.payment_hash self.paymentCheck = response.data.payment_hash
dismissMsg = self.$q.notify({ dialog.dismissMsg = self.$q.notify({
timeout: 0, timeout: 0,
message: 'Waiting for payment...' message: 'Waiting for payment...'
}) })
self.receive = { self.receive = {
show: true, show: true,
status: 'pending', status: 'pending',
paymentReq: self.paymentReq paymentReq: self.paymentReq
} }
dialog.paymentChecker = setInterval(function () {
axios
.get('/lnticket/api/v1/tickets/' + response.data.payment_hash)
.then(function (res) {
if (res.data.paid) {
clearInterval(dialog.paymentChecker)
dialog.dismissMsg()
self.receive.show = false
self.formDialog.data.name = ''
self.formDialog.data.email = ''
self.formDialog.data.text = ''
self.$q.notify({
type: 'positive',
message: 'Sats received, thanks!',
icon: 'thumb_up'
})
}
})
}, 2000)
}) })
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
@ -206,7 +196,6 @@
}, },
created() { created() {
this.wallet.inkey = '{{form_wallet}}' this.wallet.inkey = '{{form_wallet}}'
this.startPaymentNotifier()
} }
}) })
</script> </script>

View File

@ -325,9 +325,9 @@
computed: { computed: {
flatRate: function () { flatRate: function () {
if (this.formDialog.data.flatrate) { if (this.formDialog.data.flatrate) {
return 'Charge per word'
} else {
return 'Charge flat rate' return 'Charge flat rate'
} else {
return 'Charge per word'
} }
} }
}, },