fix: multiple ws connections (#2907)

This commit is contained in:
Vlad Stan 2025-01-23 13:05:35 +02:00 committed by GitHub
parent 273ab9781f
commit 56a4b702f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

File diff suppressed because one or more lines are too long

View file

@ -450,15 +450,16 @@ if (!window.g) {
wallets: [], wallets: [],
payments: [], payments: [],
allowedThemes: null, allowedThemes: null,
langs: [] langs: [],
walletEventListeners: []
}) })
} }
window.windowMixin = { window.windowMixin = {
inject: ['g'],
i18n: window.i18n, i18n: window.i18n,
data() { data() {
return { return {
g: window.g,
toggleSubs: true, toggleSubs: true,
updatePayments: false, updatePayments: false,
updatePaymentsHash: '', updatePaymentsHash: '',
@ -469,7 +470,7 @@ window.windowMixin = {
gradientChoice: gradientChoice:
this.$q.localStorage.getItem('lnbits.gradientBg') || false, this.$q.localStorage.getItem('lnbits.gradientBg') || false,
isUserAuthorized: false, isUserAuthorized: false,
eventListeners: [], walletEventListeners: [],
backgroundImage: '' backgroundImage: ''
} }
}, },
@ -487,9 +488,10 @@ window.windowMixin = {
this.refreshRoute() this.refreshRoute()
}, },
paymentEvents() { paymentEvents() {
this.g.walletEventListeners = this.g.walletEventListeners || []
this.g.user.wallets.forEach(wallet => { this.g.user.wallets.forEach(wallet => {
if (!this.eventListeners.includes(wallet.id)) { if (!this.g.walletEventListeners.includes(wallet.id)) {
this.eventListeners.push(wallet.id) this.g.walletEventListeners.push(wallet.id)
LNbits.events.onInvoicePaid(wallet, data => { LNbits.events.onInvoicePaid(wallet, data => {
const walletIndex = this.g.user.wallets.findIndex( const walletIndex = this.g.user.wallets.findIndex(
w => w.id === wallet.id w => w.id === wallet.id