Fix LNbits 1.4 compatibility: add null guards for g.user.wallets
Some checks failed
CI / lint (push) Waiting to run
CI / tests (3.10) (push) Blocked by required conditions
CI / tests (3.9) (push) Blocked by required conditions
CI / lint (pull_request) Has been cancelled
/ release (push) Has been cancelled
CI / tests (3.10) (pull_request) Has been cancelled
CI / tests (3.9) (pull_request) Has been cancelled
/ pullrequest (push) Has been cancelled

LNbits 1.4 changed g.user initialization (PR #3615), moving it from
windowMixin to base.html. This means g.user can be null during initial
Vue template evaluation.

- Use optional chaining g.user?.wallets || [] in template
- Add null guard before accessing this.g.user.wallets in JS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
padreug 2026-01-05 11:11:19 +01:00
parent cd0d958c2c
commit 25be6cff87
2 changed files with 5 additions and 5 deletions

View file

@ -181,13 +181,13 @@ window.app = Vue.createApp({
this.lamassuConfig = data this.lamassuConfig = data
// When opening config dialog, populate the selected wallets if they exist // When opening config dialog, populate the selected wallets if they exist
if (data && data.source_wallet_id) { if (data && data.source_wallet_id && this.g.user?.wallets) {
const wallet = this.g.user.wallets.find(w => w.id === data.source_wallet_id) const wallet = this.g.user.wallets.find(w => w.id === data.source_wallet_id)
if (wallet) { if (wallet) {
this.configDialog.data.selectedWallet = wallet this.configDialog.data.selectedWallet = wallet
} }
} }
if (data && data.commission_wallet_id) { if (data && data.commission_wallet_id && this.g.user?.wallets) {
const commissionWallet = this.g.user.wallets.find(w => w.id === data.commission_wallet_id) const commissionWallet = this.g.user.wallets.find(w => w.id === data.commission_wallet_id)
if (commissionWallet) { if (commissionWallet) {
this.configDialog.data.selectedCommissionWallet = commissionWallet this.configDialog.data.selectedCommissionWallet = commissionWallet

View file

@ -547,7 +547,7 @@
<q-select <q-select
filled filled
dense dense
:options="g.user.wallets" :options="g.user?.wallets || []"
v-model="configDialog.data.selectedWallet" v-model="configDialog.data.selectedWallet"
label="Source Wallet for DCA Distributions *" label="Source Wallet for DCA Distributions *"
option-label="name" option-label="name"
@ -557,7 +557,7 @@
<q-select <q-select
filled filled
dense dense
:options="g.user.wallets" :options="g.user?.wallets || []"
v-model="configDialog.data.selectedCommissionWallet" v-model="configDialog.data.selectedCommissionWallet"
label="Commission Wallet (Optional)" label="Commission Wallet (Optional)"
option-label="name" option-label="name"