mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-05 19:22:34 +02:00
refactor: extract store functions
This commit is contained in:
@@ -78,7 +78,11 @@ page_container %}
|
|||||||
<q-tr :props="props">
|
<q-tr :props="props">
|
||||||
<q-td key="status" :props="props">
|
<q-td key="status" :props="props">
|
||||||
<div v-if="props.row.status == 'pending'">
|
<div v-if="props.row.status == 'pending'">
|
||||||
<q-icon @click="showInvoiceDialog(props.row)" name="settings_ethernet" color="grey">
|
<q-icon
|
||||||
|
@click="showInvoiceDialog(props.row)"
|
||||||
|
name="settings_ethernet"
|
||||||
|
color="grey"
|
||||||
|
>
|
||||||
<q-tooltip>Pending</q-tooltip>
|
<q-tooltip>Pending</q-tooltip>
|
||||||
</q-icon>
|
</q-icon>
|
||||||
<q-badge
|
<q-badge
|
||||||
@@ -494,7 +498,7 @@ page_container %}
|
|||||||
amount: 0,
|
amount: 0,
|
||||||
memo: '',
|
memo: '',
|
||||||
bolt11: '',
|
bolt11: '',
|
||||||
hash: '',
|
hash: ''
|
||||||
},
|
},
|
||||||
showInvoiceDetails: false,
|
showInvoiceDetails: false,
|
||||||
tokens: [],
|
tokens: [],
|
||||||
@@ -844,7 +848,6 @@ page_container %}
|
|||||||
this.showInvoiceDetails = true
|
this.showInvoiceDetails = true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
requestInvoice: async function () {
|
requestInvoice: async function () {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
@@ -860,10 +863,7 @@ page_container %}
|
|||||||
date: currentDateStr(),
|
date: currentDateStr(),
|
||||||
status: 'pending'
|
status: 'pending'
|
||||||
})
|
})
|
||||||
localStorage.setItem(
|
this.storeBuyOrders()
|
||||||
'cashu.buyOrders',
|
|
||||||
JSON.stringify(this.buyOrders)
|
|
||||||
)
|
|
||||||
const amounts = splitAmount(this.buyData.amount)
|
const amounts = splitAmount(this.buyData.amount)
|
||||||
await this.requestTokens(amounts, this.buyData.hash)
|
await this.requestTokens(amounts, this.buyData.hash)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -893,15 +893,18 @@ page_container %}
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
recheckBuyOrder: async function(hash) {
|
recheckBuyOrder: async function (hash) {
|
||||||
console.log('### recheckBuyOrder', hash)
|
console.log('### recheckBuyOrder', hash)
|
||||||
const tokens = this.tokens.find(bt => bt.hash = hash)
|
const tokens = this.tokens.find(bt => (bt.hash = hash))
|
||||||
if (!tokens) {
|
if (!tokens) {
|
||||||
console.error('####### no token for hash', hash)
|
console.error('####### no token for hash', hash)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const promises = await this.fetchPromisesFromMint(hash, tokens.blindedMessages)
|
const promises = await this.fetchPromisesFromMint(
|
||||||
if (promises && promises.length){
|
hash,
|
||||||
|
tokens.blindedMessages
|
||||||
|
)
|
||||||
|
if (promises && promises.length) {
|
||||||
tokens.promises = promises
|
tokens.promises = promises
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -923,16 +926,12 @@ page_container %}
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
requestTokens: async function (amounts, paymentHash) {
|
requestTokens: async function (amounts, paymentHash) {
|
||||||
const newTokens = await this.buildTokens(amounts, paymentHash)
|
const newTokens = await this.buildTokens(amounts, paymentHash)
|
||||||
this.tokens.push(newTokens)
|
this.tokens.push(newTokens)
|
||||||
localStorage.setItem(
|
this.storeTokens()
|
||||||
'cashu.tokens',
|
|
||||||
JSON.stringify(this.tokens, bigIntStringify)
|
|
||||||
)
|
|
||||||
console.log('### this.tokens', this.tokens)
|
console.log('### this.tokens', this.tokens)
|
||||||
await this.fetchPromisesFromMint(paymentHash, newTokens.newTokens)
|
await this.fetchPromisesFromMint(paymentHash, newTokens.newTokens)
|
||||||
},
|
},
|
||||||
@@ -980,6 +979,16 @@ page_container %}
|
|||||||
C: {C, secret: secrets[i]}
|
C: {C, secret: secrets[i]}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
storeBuyOrders: function () {
|
||||||
|
localStorage.setItem('cashu.buyOrders', JSON.stringify(this.buyOrders))
|
||||||
|
},
|
||||||
|
storeTokens: function () {
|
||||||
|
localStorage.setItem(
|
||||||
|
'cashu.tokens',
|
||||||
|
JSON.stringify(this.tokens, bigIntStringify)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
Reference in New Issue
Block a user