fix: mapping of user was done each time component was initialised (#3573)

This commit is contained in:
dni ⚡ 2025-11-26 13:21:36 +01:00 committed by GitHub
parent baa9a35773
commit 21505471d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 40 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -15,11 +15,7 @@ window.LNbits = {
extra: data.extra ?? {}
}
const mapWallet = this.wallet
obj.wallets = obj.wallets
.map(obj => {
return mapWallet(obj)
})
.sort((a, b) => {
obj.wallets = obj.wallets.map(mapWallet).sort((a, b) => {
if (a.extra.pinned !== b.extra.pinned) {
return a.extra.pinned ? -1 : 1
}

View file

@ -86,6 +86,12 @@ window.i18n = new VueI18n.createI18n({
})
window.app.mixin({
data() {
return {
g: window.g,
...WINDOW_SETTINGS
}
},
computed: {
isVueRoute() {
const currentPath = window.location.pathname

View file

@ -1,12 +1,4 @@
window.windowMixin = {
i18n: window.i18n,
data() {
return {
g: window.g,
utils: window._lnbitsUtils,
...WINDOW_SETTINGS
}
},
methods: {
openNewWalletDialog(walletType = 'lightning') {
this.g.newWalletType = walletType
@ -115,16 +107,11 @@ window.windowMixin = {
})
}
},
async created() {
if (window.user) {
this.g.user = Vue.reactive(window.LNbits.map.user(window.user))
created() {
// map jinja variable once on pageload
if (window.user && !this.g.user) {
this.g.user = window.LNbits.map.user(window.user)
this.paymentEvents()
}
if (window.wallet) {
this.g.wallet = Vue.reactive(window.LNbits.map.wallet(window.wallet))
}
if (window.extensions) {
this.g.extensions = Vue.reactive(window.extensions)
}
}
}

View file

@ -1,18 +1,8 @@
{% macro window_vars(user, wallet, extensions, extension_data) -%}
{% macro window_vars(user) -%}
<script id="window-vars-script">
window.extensions = JSON.parse('{{ EXTENSIONS | tojson | safe }}');
{% if extension_data %}
window.extension_data = {{ extension_data | tojson | safe }};
{% endif %}
{% if currencies %}
window.currencies = {{ currencies | tojson | safe }};
{% endif %}
{% if user %}
window.user = JSON.parse({{ user | tojson | safe }});
{% endif %}
{% if wallet %}
window.wallet = JSON.parse({{ wallet | tojson | safe }});
{% endif %}
</script>
<script>
//Needed for Vue to create the app on first load (although called on every page, its only loaded once)