Skip to content

Commit

Permalink
Fix errors (#108)
Browse files Browse the repository at this point in the history
* fix: correct currency format for sats
* fix: correct sat amount output
* fix: wait for exchange rate
  • Loading branch information
talvasconcelos authored Nov 5, 2024
1 parent a117a58 commit b86fba2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions templates/tpos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,9 @@ <h6 class="text-subtitle1 q-my-none">
itemFormatPrice(price, id) {
const tpos = id.split(':')[0]
const currency = _.findWhere(this.tposs, {id: tpos}).currency
if(currency == 'sats') {
return price + ' sats'
}
return LNbits.utils.formatCurrency(Number(price).toFixed(2), currency)
},
openItemDialog(id) {
Expand Down
13 changes: 8 additions & 5 deletions templates/tpos/tpos.html
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ <h5 class="q-mt-none q-mb-sm">
computed: {
amount: function () {
if (!this.stack.length) return 0.0
if (this.currency == 'sats') return Number(this.stack.join(""))
return (
this.stack.reduce((acc, dig) => acc * 10 + dig, 0) *
(this.currency == 'sats' ? 1 : 0.01)
Expand Down Expand Up @@ -1246,11 +1247,13 @@ <h5 class="q-mt-none q-mb-sm">
getRates() {
if (this.currency == 'sats') {
this.exchangeRate = 1
this.$q.loading.hide()
} else {
LNbits.api
.request('GET', `/tpos/api/v1/rate/${this.currency}`)
.then(response => {
this.exchangeRate = response.data.rate
this.$q.loading.hide()
})
.catch(e => console.error(e))
}
Expand Down Expand Up @@ -1321,9 +1324,9 @@ <h5 class="q-mt-none q-mb-sm">
}
}
},
created: function () {
var getRates = this.getRates
getRates()
created() {
this.$q.loading.show()
this.getRates()
this.pinDisabled = JSON.parse('{{ tpos.withdrawpindisabled | tojson }}')
this.tip_options =
'{{ tpos.tip_options | tojson }}' == 'null'
Expand Down Expand Up @@ -1388,8 +1391,8 @@ <h5 class="q-mt-none q-mb-sm">
event.preventDefault()
})

setInterval(function () {
getRates()
setInterval(() => {
this.getRates()
}, 120000)
}
})
Expand Down

0 comments on commit b86fba2

Please sign in to comment.