fix: mapping of user was done each time component was initialised (#3573)
This commit is contained in:
parent
baa9a35773
commit
21505471d5
6 changed files with 19 additions and 40 deletions
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -15,16 +15,12 @@ window.LNbits = {
|
|||
extra: data.extra ?? {}
|
||||
}
|
||||
const mapWallet = this.wallet
|
||||
obj.wallets = obj.wallets
|
||||
.map(obj => {
|
||||
return mapWallet(obj)
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.extra.pinned !== b.extra.pinned) {
|
||||
return a.extra.pinned ? -1 : 1
|
||||
}
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
obj.wallets = obj.wallets.map(mapWallet).sort((a, b) => {
|
||||
if (a.extra.pinned !== b.extra.pinned) {
|
||||
return a.extra.pinned ? -1 : 1
|
||||
}
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
obj.walletOptions = obj.wallets.map(obj => {
|
||||
return {
|
||||
label: [obj.name, ' - ', obj.id.substring(0, 5), '...'].join(''),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue