chore: cleanup base.html, minor issue and g.user initialisation (#3615)

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
dni ⚡
2025-12-04 10:21:40 +01:00
committed by GitHub
co-authored by Vlad Stan
parent 1fe35070f4
commit 73634e5161
8 changed files with 24 additions and 25 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
-3
View File
@@ -50,9 +50,6 @@ window.LNbits = {
}
newWallet.msat = data.balance_msat
newWallet.sat = Math.floor(data.balance_msat / 1000)
newWallet.fsat = new Intl.NumberFormat(window.i18n.global.locale).format(
newWallet.sat
)
if (newWallet.walletType === 'lightning-shared') {
const perms = newWallet.sharePermissions
newWallet.canReceivePayments = perms.includes('receive-payments')
+1 -1
View File
@@ -360,7 +360,7 @@ window.app.component('lnbits-update-balance', {
props: ['wallet_id', 'small_btn'],
computed: {
admin() {
return user.super_user
return this.g.user?.super_user === true
}
},
data() {
+2 -3
View File
@@ -26,8 +26,7 @@ window.PageExtensions = {
selectedRelease: null,
uninstallAndDropDb: false,
maxStars: 5,
paylinkWebsocket: null,
user: null
paylinkWebsocket: null
}
},
watch: {
@@ -636,7 +635,7 @@ window.PageExtensions = {
},
async created() {
this.extensions = await this.fetchAllExtensions()
this.extbuilderEnabled = user.admin || this.LNBITS_EXT_BUILDER
this.extbuilderEnabled = this.g.user.admin || this.LNBITS_EXT_BUILDER
const extId = window.location.hash.replace('#', '')
const ext = this.extensions.find(ext => ext.id === extId)
+1 -6
View File
@@ -20,14 +20,12 @@ window.windowMixin = {
console.error('ws message no payment', data)
return
}
// update sidebar wallet balances
this.g.user.wallets.forEach(w => {
if (w.id === data.payment.wallet_id) {
w.sat = data.wallet_balance
}
})
// if current wallet, update balance and payments
if (this.g.wallet.id === data.payment.wallet_id) {
this.g.wallet.sat = data.wallet_balance
@@ -35,7 +33,6 @@ window.windowMixin = {
this.g.updatePayments = !this.g.updatePayments
this.g.updatePaymentsHash = !this.g.updatePaymentsHash
}
// NOTE: react only on incoming payments for now
if (data.payment.amount > 0) {
eventReaction(data.wallet_balance * 1000)
@@ -72,9 +69,7 @@ window.windowMixin = {
}
},
created() {
// map jinja variable once on pageload
if (window.user && !this.g.user) {
this.g.user = window.LNbits.map.user(window.user)
if (this.g.user && this.g.walletEventListeners.length === 0) {
this.paymentEvents()
}
}