fixed updating paid tickets on index.html

This commit is contained in:
Tiago vasconcelos 2021-06-16 11:23:58 +01:00
parent bb1253f30e
commit b490d9f260
3 changed files with 36 additions and 12 deletions

View File

@ -25,10 +25,12 @@ async def on_invoice_paid(payment: Payment) -> None:
# not a lnticket invoice
return
ticket = await get_ticket(payment.payment_hash)
ticket = await get_ticket(payment.checking_id)
if not ticket:
print("this should never happen", payment)
return
await payment.set_pending(False)
await set_ticket_paid(payment_hash=payment.payment_hash)
await set_ticket_paid(payment.payment_hash)
_ticket = await get_ticket(payment.checking_id)
print('ticket', _ticket)

View File

@ -77,7 +77,7 @@
{% endblock %} {% block scripts %}
<script>
console.log('{{ form_costpword }}')
//console.log('{{ form_costpword }}')
Vue.component(VueQrcode.name, VueQrcode)
new Vue({
@ -139,7 +139,7 @@
},
startPaymentNotifier() {
this.cancelListener()
console.log(this.wallet)
this.cancelListener = LNbits.events.onInvoicePaid(
this.wallet,
payment => {

View File

@ -90,7 +90,7 @@
<div class="col">
<h5 class="text-subtitle1 q-my-none">Tickets</h5>
</div>
<div class="col-auto">
<!-- <div class="col-auto">
<q-btn
flat
color="grey"
@ -99,7 +99,7 @@
@click="getTickets"
><q-tooltip> Refresh Tickets </q-tooltip></q-btn
>
</div>
</div> -->
<div class="col-auto">
<q-btn flat color="grey" @click="exportticketsCSV"
>Export to CSV</q-btn
@ -240,7 +240,7 @@
</div>
{% endblock %} {% block scripts %} {{ window_vars(user) }}
<script>
var mapLNTicket = function (obj) {
const mapLNTicket = function (obj) {
obj.date = Quasar.utils.date.formatDate(
new Date(obj.time * 1000),
'YYYY-MM-DD HH:mm'
@ -291,7 +291,8 @@
{name: 'name', align: 'left', label: 'Name', field: 'name'},
{name: 'email', align: 'left', label: 'Email', field: 'email'},
{name: 'ltext', align: 'left', label: 'Ticket', field: 'ltext'},
{name: 'sats', align: 'left', label: 'Cost', field: 'sats'}
{name: 'sats', align: 'left', label: 'Cost', field: 'sats'},
{name: 'paid', align: 'left', label: 'Paid', field: 'paid'}
],
pagination: {
rowsPerPage: 10
@ -300,7 +301,8 @@
formDialog: {
show: false,
data: {}
}
},
cancelListener: () => {}
}
},
methods: {
@ -314,9 +316,12 @@
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.tickets = response.data.map(function (obj) {
return mapLNTicket(obj)
})
self.tickets = response.data
.map(function (obj) {
if (!obj?.paid) return
return mapLNTicket(obj)
})
.filter(v => v)
})
},
deleteTicket: function (ticketId) {
@ -446,6 +451,22 @@
},
exportformsCSV: function () {
LNbits.utils.exportCSV(this.formsTable.columns, this.forms)
},
startPaymentNotifier() {
this.cancelListener()
this.cancelListener = LNbits.events.onInvoicePaid(
this.g.user.wallets[0],
payment => {
this.getTickets()
this.$q.notify({
type: 'positive',
message: 'Sent, thank you!',
icon: 'thumb_up'
})
}
)
}
},
@ -453,6 +474,7 @@
if (this.g.user.wallets.length) {
this.getTickets()
this.getForms()
this.startPaymentNotifier()
}
}
})