mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-02 14:09:26 +02:00
refactor: extract methods to utils
This commit is contained in:
@@ -282,41 +282,10 @@
|
|||||||
<style></style>
|
<style></style>
|
||||||
<!-- todo: use config mempool -->
|
<!-- todo: use config mempool -->
|
||||||
<script src="https://mempool.space/mempool.js"></script>
|
<script src="https://mempool.space/mempool.js"></script>
|
||||||
|
<script src="{{ url_for('satspay_static', path='js/utils.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
Vue.component(VueQrcode.name, VueQrcode)
|
Vue.component(VueQrcode.name, VueQrcode)
|
||||||
|
|
||||||
const mapCharge = obj => {
|
|
||||||
obj._data = _.clone(obj)
|
|
||||||
obj.theTime = obj.time * 60 - (Date.now() / 1000 - obj.timestamp)
|
|
||||||
obj.time = obj.time + 'mins'
|
|
||||||
|
|
||||||
if (obj.time_elapsed) {
|
|
||||||
obj.date = 'Time elapsed'
|
|
||||||
} else {
|
|
||||||
obj.date = Quasar.utils.date.formatDate(
|
|
||||||
new Date((obj.theTime - 3600) * 1000),
|
|
||||||
'HH:mm:ss'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
obj.displayUrl = ['/satspay/', obj.id].join('')
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
||||||
const retryWithDelay = async function (fn, retryCount = 0) {
|
|
||||||
try {
|
|
||||||
await sleep(25)
|
|
||||||
// Do not return the call directly, use result.
|
|
||||||
// Otherwise the error will not be cought in this try-catch block.
|
|
||||||
const result = await fn()
|
|
||||||
return result
|
|
||||||
} catch (err) {
|
|
||||||
if (retryCount > 100) throw err
|
|
||||||
await sleep((retryCount + 1) * 1000)
|
|
||||||
return retryWithDelay(fn, retryCount + 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [windowMixin],
|
mixins: [windowMixin],
|
||||||
|
Reference in New Issue
Block a user