Switched jukebox back to polling until it can use listeners properly
This commit is contained in:
parent
734bf1bcd5
commit
094943e293
|
@ -107,7 +107,6 @@
|
|||
return {
|
||||
currentPlaylist: [],
|
||||
currentlyPlaying: {},
|
||||
cancelListener: () => {},
|
||||
playlists: {},
|
||||
playlist: '',
|
||||
heavyList: [],
|
||||
|
@ -124,7 +123,10 @@
|
|||
artist: '',
|
||||
image: '',
|
||||
id: '',
|
||||
showQR: false
|
||||
showQR: false,
|
||||
data: null,
|
||||
dismissMsg: null,
|
||||
paymentChecker: null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -142,51 +144,9 @@
|
|||
self.receive.id = song_id
|
||||
self.receive.dialogues.first = true
|
||||
},
|
||||
startPaymentNotifier() {
|
||||
this.cancelListener()
|
||||
|
||||
this.cancelListener = LNbits.events.onInvoicePaid(
|
||||
this.selectedWallet,
|
||||
payment => {
|
||||
this.paid = true
|
||||
this.receive.dialogues.first = false
|
||||
this.receive.dialogues.second = false
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/jukebox/api/v1/jukebox/jb/invoicep/' +
|
||||
this.receive.id +
|
||||
'/{{ juke_id }}/' +
|
||||
this.receive.paymentHash
|
||||
)
|
||||
.then(response1 => {
|
||||
if (response1.data[2] == this.receive.id) {
|
||||
setTimeout(() => {
|
||||
this.getCurrent()
|
||||
}, 500)
|
||||
this.$q.notify({
|
||||
color: 'green',
|
||||
message:
|
||||
'Success! "' +
|
||||
this.receive.name +
|
||||
'" will be played soon',
|
||||
timeout: 3000
|
||||
})
|
||||
|
||||
this.paid = false
|
||||
response1 = []
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
LNbits.utils.notifyApiError(err)
|
||||
self.paid = false
|
||||
response1 = []
|
||||
})
|
||||
}
|
||||
)
|
||||
},
|
||||
getInvoice(song_id) {
|
||||
self = this
|
||||
var dialog = this.receive
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
|
@ -199,11 +159,53 @@
|
|||
self.receive.paymentReq = response.data[0][1]
|
||||
self.receive.paymentHash = response.data[0][0]
|
||||
self.receive.dialogues.second = true
|
||||
dialog.data = response.data
|
||||
|
||||
dialog.dismissMsg = self.$q.notify({
|
||||
timeout: 0,
|
||||
message: 'Waiting for payment...'
|
||||
})
|
||||
dialog.paymentChecker = setInterval(function () {
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/jukebox/api/v1/jukebox/jb/invoicep/' +
|
||||
self.receive.id +
|
||||
'/{{ juke_id }}/' +
|
||||
self.receive.paymentHash
|
||||
)
|
||||
.then(function (res) {
|
||||
console.log(
|
||||
'/jukebox/api/v1/jukebox/jb/invoicep/' +
|
||||
self.receive.id +
|
||||
'/{{ juke_id }}/' +
|
||||
self.receive.paymentHash
|
||||
)
|
||||
console.log(res.data)
|
||||
console.log(self.receive.id)
|
||||
if (res.data[2] == self.receive.id) {
|
||||
clearInterval(dialog.paymentChecker)
|
||||
dialog.dismissMsg()
|
||||
self.receive.dialogues.second = false
|
||||
|
||||
self.$q.notify({
|
||||
message: 'Processing'
|
||||
type: 'positive',
|
||||
message:
|
||||
'Success! "' +
|
||||
self.receive.name +
|
||||
'" will be played soon',
|
||||
timeout: 3000
|
||||
})
|
||||
self.receive.dialogues.first = false
|
||||
}
|
||||
})
|
||||
}, 3000)
|
||||
})
|
||||
.finally(
|
||||
setTimeout(() => {
|
||||
self.getCurrent()
|
||||
}, 500)
|
||||
)
|
||||
.catch(err => {
|
||||
self.$q.notify({
|
||||
color: 'warning',
|
||||
|
@ -249,7 +251,6 @@
|
|||
this.getCurrent()
|
||||
this.playlists = JSON.parse('{{ playlists | tojson }}')
|
||||
this.selectedWallet.inkey = '{{ inkey }}'
|
||||
this.startPaymentNotifier()
|
||||
self = this
|
||||
LNbits.api
|
||||
.request(
|
||||
|
|
|
@ -331,6 +331,7 @@ async def api_get_jukebox_invoice_paid(song_id, juke_id, pay_hash, retry=False):
|
|||
jsonify({"error": "No Jukebox"}),
|
||||
HTTPStatus.FORBIDDEN,
|
||||
)
|
||||
await api_get_jukebox_invoice_check(pay_hash, juke_id)
|
||||
jukebox_payment = await get_jukebox_payment(pay_hash)
|
||||
if jukebox_payment.paid:
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
|
Loading…
Reference in New Issue
Block a user