refactor: move copyText and formatBalance into utils (#3584)
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -95,6 +95,8 @@ window.i18n = new VueI18n.createI18n({
|
||||
window.app.mixin({
|
||||
data() {
|
||||
return {
|
||||
api: window._lnbitsApi,
|
||||
utils: window._lnbitsUtils,
|
||||
g: window.g,
|
||||
utils: window._lnbitsUtils,
|
||||
...WINDOW_SETTINGS
|
||||
@@ -107,6 +109,11 @@ window.app.mixin({
|
||||
const isVueRoute = matchedRoute?.matched?.length > 0
|
||||
return isVueRoute
|
||||
}
|
||||
},
|
||||
// backwards compatibility for extensions, should not be used in the future
|
||||
methods: {
|
||||
copyText: window._lnbitsUtils.copyText,
|
||||
formatBalance: window._lnbitsUtils.formatBalance
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
window._lnbitsUtils = {
|
||||
copyText(text, message, position) {
|
||||
Quasar.copyToClipboard(text).then(() => {
|
||||
Quasar.Notify.create({
|
||||
message: message || 'Copied to clipboard!',
|
||||
position: position || 'bottom'
|
||||
})
|
||||
})
|
||||
},
|
||||
confirmDialog(msg) {
|
||||
return Quasar.Dialog.create({
|
||||
message: msg,
|
||||
@@ -52,6 +60,12 @@ window._lnbitsUtils = {
|
||||
const timestampMs = new Date(isoDateString).getTime()
|
||||
return moment.utc(timestampMs).local().fromNow()
|
||||
},
|
||||
formatBalance(amount, denomination = 'sats') {
|
||||
if (denomination === 'sats') {
|
||||
return LNbits.utils.formatSat(amount) + ' sats'
|
||||
}
|
||||
return LNbits.utils.formatCurrency(amount / 100, denomination)
|
||||
},
|
||||
formatCurrency(value, currency) {
|
||||
return new Intl.NumberFormat(window.i18n.global.locale, {
|
||||
style: 'currency',
|
||||
|
||||
@@ -60,21 +60,6 @@ window.windowMixin = {
|
||||
}
|
||||
})
|
||||
},
|
||||
formatBalance(amount) {
|
||||
if (LNBITS_DENOMINATION != 'sats') {
|
||||
return LNbits.utils.formatCurrency(amount / 100, LNBITS_DENOMINATION)
|
||||
} else {
|
||||
return LNbits.utils.formatSat(amount) + ' sats'
|
||||
}
|
||||
},
|
||||
copyText(text, message, position) {
|
||||
Quasar.copyToClipboard(text).then(() => {
|
||||
Quasar.Notify.create({
|
||||
message: message || 'Copied to clipboard!',
|
||||
position: position || 'bottom'
|
||||
})
|
||||
})
|
||||
},
|
||||
refreshRoute() {
|
||||
const path = window.location.pathname
|
||||
console.log(path)
|
||||
|
||||
Reference in New Issue
Block a user