mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-11 13:02:39 +02:00
one worker at a time
This commit is contained in:
@@ -1523,12 +1523,17 @@ page_container %}
|
|||||||
},
|
},
|
||||||
|
|
||||||
//////////// API ///////////
|
//////////// API ///////////
|
||||||
|
clearAllWorkers: function () {
|
||||||
invoiceCheckWorker: async function () {
|
|
||||||
let nInterval = 0
|
|
||||||
if (this.invoiceCheckListener) {
|
if (this.invoiceCheckListener) {
|
||||||
clearInterval(this.invoiceCheckListener)
|
clearInterval(this.invoiceCheckListener)
|
||||||
}
|
}
|
||||||
|
if (this.tokensCheckSpendableListener) {
|
||||||
|
clearInterval(this.tokensCheckSpendableListener)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
invoiceCheckWorker: async function () {
|
||||||
|
let nInterval = 0
|
||||||
|
this.clearAllWorkers()
|
||||||
this.invoiceCheckListener = setInterval(async () => {
|
this.invoiceCheckListener = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
nInterval += 1
|
nInterval += 1
|
||||||
@@ -1536,9 +1541,9 @@ page_container %}
|
|||||||
// exit loop after 2m
|
// exit loop after 2m
|
||||||
if (nInterval > 40) {
|
if (nInterval > 40) {
|
||||||
console.log('### stopping invoice check worker')
|
console.log('### stopping invoice check worker')
|
||||||
clearInterval(this.invoiceCheckListener)
|
this.clearAllWorkers()
|
||||||
}
|
}
|
||||||
console.log('### setInterval', nInterval)
|
console.log('### invoiceCheckWorker setInterval', nInterval)
|
||||||
console.log(this.invoiceData)
|
console.log(this.invoiceData)
|
||||||
|
|
||||||
// this will throw an error if the invoice is pending
|
// this will throw an error if the invoice is pending
|
||||||
@@ -1546,7 +1551,7 @@ page_container %}
|
|||||||
|
|
||||||
// only without error (invoice paid) will we reach here
|
// only without error (invoice paid) will we reach here
|
||||||
console.log('### stopping invoice check worker')
|
console.log('### stopping invoice check worker')
|
||||||
clearInterval(this.invoiceCheckListener)
|
this.clearAllWorkers()
|
||||||
this.invoiceData.bolt11 = ''
|
this.invoiceData.bolt11 = ''
|
||||||
this.showInvoiceDetails = false
|
this.showInvoiceDetails = false
|
||||||
if (window.navigator.vibrate) navigator.vibrate(200)
|
if (window.navigator.vibrate) navigator.vibrate(200)
|
||||||
@@ -1981,19 +1986,16 @@ page_container %}
|
|||||||
|
|
||||||
checkTokenSpendableWorker: async function () {
|
checkTokenSpendableWorker: async function () {
|
||||||
let nInterval = 0
|
let nInterval = 0
|
||||||
if (this.tokensCheckSpendableListener) {
|
this.clearAllWorkers()
|
||||||
clearInterval(this.tokensCheckSpendableListener)
|
|
||||||
}
|
|
||||||
this.tokensCheckSpendableListener = setInterval(async () => {
|
this.tokensCheckSpendableListener = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
nInterval += 1
|
nInterval += 1
|
||||||
|
|
||||||
// exit loop after 2m
|
// exit loop after 2m
|
||||||
if (nInterval > 24) {
|
if (nInterval > 24) {
|
||||||
console.log('### stopping token check worker')
|
console.log('### stopping token check worker')
|
||||||
clearInterval(this.tokensCheckSpendableListener)
|
this.clearAllWorkers()
|
||||||
}
|
}
|
||||||
console.log('### setInterval', nInterval)
|
console.log('### checkTokenSpendableWorker setInterval', nInterval)
|
||||||
console.log(this.sendData)
|
console.log(this.sendData)
|
||||||
|
|
||||||
// this will throw an error if the invoice is pending
|
// this will throw an error if the invoice is pending
|
||||||
@@ -2003,7 +2005,7 @@ page_container %}
|
|||||||
)
|
)
|
||||||
if (paid) {
|
if (paid) {
|
||||||
console.log('### stopping token check worker')
|
console.log('### stopping token check worker')
|
||||||
clearInterval(this.tokensCheckSpendableListener)
|
this.clearAllWorkers()
|
||||||
this.sendData.tokens = ''
|
this.sendData.tokens = ''
|
||||||
this.showSendTokens = false
|
this.showSendTokens = false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user