feat: move disclaimer from wallet.html into vue component (#3536)

This commit is contained in:
dni ⚡ 2025-11-21 08:39:17 +01:00 committed by GitHub
parent 9f4ed53888
commit 5346ac47b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 66 additions and 62 deletions

View file

@ -38,7 +38,7 @@
'q-pt-sm': g.fiatTracking, 'q-pt-sm': g.fiatTracking,
'q-pt-lg': !g.fiatTracking 'q-pt-lg': !g.fiatTracking
}" }"
v-if="!isFiatPriority || !g.fiatTracking" v-if="!g.isFiatPriority || !g.fiatTracking"
style="height: 100px" style="height: 100px"
> >
<div class="col-7"> <div class="col-7">
@ -75,7 +75,7 @@
<div <div
class="column" class="column"
v-if="isFiatPriority && g.fiatTracking" v-if="g.isFiatPriority && g.fiatTracking"
:class="{ :class="{
'q-pt-sm': g.fiatTracking, 'q-pt-sm': g.fiatTracking,
'q-pt-lg': !g.fiatTracking 'q-pt-lg': !g.fiatTracking
@ -810,7 +810,7 @@
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card"> <q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<div v-if="parse.invoice"> <div v-if="parse.invoice">
<div class="column content-center text-center q-mb-md"> <div class="column content-center text-center q-mb-md">
<div v-if="!isFiatPriority"> <div v-if="!g.isFiatPriority">
<h4 class="q-my-none text-bold"> <h4 class="q-my-none text-bold">
<span v-text="formatBalance(parse.invoice.sat)"></span> <span v-text="formatBalance(parse.invoice.sat)"></span>
</h4> </h4>
@ -832,7 +832,7 @@
></q-btn> ></q-btn>
</div> </div>
<div v-if="g.fiatTracking"> <div v-if="g.fiatTracking">
<div v-if="isFiatPriority"> <div v-if="g.isFiatPriority">
<h5 class="q-my-none text-bold"> <h5 class="q-my-none text-bold">
<span v-text="formatBalance(parse.invoice.sat)"></span> <span v-text="formatBalance(parse.invoice.sat)"></span>
</h5> </h5>
@ -1257,31 +1257,6 @@
> >
</q-btn> </q-btn>
</div> </div>
<q-dialog v-model="disclaimerDialog.show" position="top">
<q-card class="q-pa-lg">
<h6
class="q-my-md text-primary"
v-text="$t('disclaimer_dialog_title')"
></h6>
<p class="whitespace-pre-line" v-text="$t('disclaimer_dialog')"></p>
<div class="row q-mt-lg">
<q-btn
outline
color="grey"
type="a"
href="/account"
:label="$t('my_account')"
></q-btn>
<q-btn
v-close-popup
flat
color="grey"
class="q-ml-auto"
:label="$t('i_understand')"
></q-btn>
</div>
</q-card>
</q-dialog>
{% endblock %} {% endblock %}
</div> </div>
</div> </div>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
window.app.component('lnbits-disclaimer', {
template: '#lnbits-disclaimer',
mixins: [window.windowMixin],
computed: {
showDisclaimer() {
return !g.disclaimerShown && g.isUserAuthorized
}
}
})

View file

@ -1,6 +1,12 @@
window.app.component('lnbits-theme', { window.app.component('lnbits-theme', {
mixins: [window.windowMixin], mixins: [window.windowMixin],
watch: { watch: {
'g.disclaimerShown'(val) {
this.$q.localStorage.setItem('lnbits.disclaimerShown', val)
},
'g.isFiatPriority'(val) {
this.$q.localStorage.setItem('lnbits.isFiatPriority', val)
},
'g.reactionChoice'(val) { 'g.reactionChoice'(val) {
this.$q.localStorage.set('lnbits.reactions', val) this.$q.localStorage.set('lnbits.reactions', val)
}, },

View file

@ -25,9 +25,11 @@ window.g = Vue.reactive({
newWalletType: 'lightning', newWalletType: 'lightning',
updatePayments: false, updatePayments: false,
updatePaymentsHash: '', updatePaymentsHash: '',
locale: localStore('lnbits.lang', navigator.languages[1] ?? 'en'),
disclaimerShown: localStore('lnbits.disclaimerShown', false),
isFiatPriority: localStore('lnbits.isFiatPriority', false),
mobileSimple: localStore('lnbits.mobileSimple', true), mobileSimple: localStore('lnbits.mobileSimple', true),
walletFlip: localStore('lnbits.walletFlip', false), walletFlip: localStore('lnbits.walletFlip', false),
locale: localStore('lnbits.lang', navigator.languages[1] ?? 'en'),
darkChoice: localStore('lnbits.darkMode', true), darkChoice: localStore('lnbits.darkMode', true),
themeChoice: localStore('lnbits.theme', WINDOW_SETTINGS.LNBITS_DEFAULT_THEME), themeChoice: localStore('lnbits.theme', WINDOW_SETTINGS.LNBITS_DEFAULT_THEME),
borderChoice: localStore( borderChoice: localStore(
@ -66,3 +68,9 @@ addEventListener('online', event => {
console.log('back online', event) console.log('back online', event)
this.g.offline = false this.g.offline = false
}) })
if (navigator.serviceWorker != null) {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('Registered events at scope: ', registration.scope)
})
}

View file

@ -45,10 +45,6 @@ window.WalletPageLogic = {
payment_hash: null payment_hash: null
} }
}, },
disclaimerDialog: {
show: false,
location: window.location
},
icon: { icon: {
show: false, show: false,
data: {}, data: {},
@ -111,7 +107,6 @@ window.WalletPageLogic = {
}, },
hasNfc: false, hasNfc: false,
nfcReaderAbortController: null, nfcReaderAbortController: null,
isFiatPriority: false,
formattedFiatAmount: 0, formattedFiatAmount: 0,
formattedExchange: null, formattedExchange: null,
paymentFilter: { paymentFilter: {
@ -201,7 +196,7 @@ window.WalletPageLogic = {
this.receive.data.memo = null this.receive.data.memo = null
this.receive.data.internalMemo = null this.receive.data.internalMemo = null
this.receive.data.payment_hash = null this.receive.data.payment_hash = null
this.receive.unit = this.isFiatPriority this.receive.unit = this.g.isFiatPriority
? this.g.wallet.currency || 'sat' ? this.g.wallet.currency || 'sat'
: 'sat' : 'sat'
this.receive.minMax = [0, 2100000000000000] this.receive.minMax = [0, 2100000000000000]
@ -777,17 +772,15 @@ window.WalletPageLogic = {
}) })
}, },
swapBalancePriority() { swapBalancePriority() {
this.isFiatPriority = !this.isFiatPriority this.g.isFiatPriority = !this.g.isFiatPriority
this.receive.unit = this.isFiatPriority this.receive.unit = this.g.isFiatPriority
? this.g.wallet.currency || 'sat' ? this.g.wallet.currency || 'sat'
: 'sat' : 'sat'
this.$q.localStorage.setItem('lnbits.isFiatPriority', this.isFiatPriority)
}, },
handleFiatTracking() { handleFiatTracking() {
this.g.fiatTracking = !this.g.fiatTracking this.g.fiatTracking = !this.g.fiatTracking
if (!this.g.fiatTracking) { if (!this.g.fiatTracking) {
this.$q.localStorage.setItem('lnbits.isFiatPriority', false) this.g.isFiatPriority = false
this.isFiatPriority = false
this.update.currency = '' this.update.currency = ''
this.g.wallet.currency = '' this.g.wallet.currency = ''
this.updateWallet({currency: ''}) this.updateWallet({currency: ''})
@ -892,24 +885,5 @@ window.WalletPageLogic = {
}, },
deep: true deep: true
} }
},
async mounted() {
if (!Quasar.LocalStorage.getItem('lnbits.disclaimerShown')) {
this.disclaimerDialog.show = true
Quasar.LocalStorage.setItem('lnbits.disclaimerShown', true)
Quasar.LocalStorage.setItem('lnbits.reactions', 'confettiTop')
}
if (Quasar.LocalStorage.getItem('lnbits.isFiatPriority')) {
this.isFiatPriority = Quasar.LocalStorage.getItem('lnbits.isFiatPriority')
} else {
this.isFiatPriority = false
Quasar.LocalStorage.setItem('lnbits.isFiatPriority', false)
} }
} }
}
if (navigator.serviceWorker != null) {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('Registered events at scope: ', registration.scope)
})
}

View file

@ -74,6 +74,7 @@
"js/components/lnbits-home-logos.js", "js/components/lnbits-home-logos.js",
"js/components/lnbits-qrcode.js", "js/components/lnbits-qrcode.js",
"js/components/lnbits-qrcode-lnurl.js", "js/components/lnbits-qrcode-lnurl.js",
"js/components/lnbits-disclaimer.js",
"js/components/lnbits-footer.js", "js/components/lnbits-footer.js",
"js/components/lnbits-header.js", "js/components/lnbits-header.js",
"js/components/lnbits-header-wallets.js", "js/components/lnbits-header-wallets.js",

View file

@ -33,6 +33,7 @@
<body data-theme="bitcoin"> <body data-theme="bitcoin">
<div id="vue"> <div id="vue">
<q-layout view="hHh lpR lfr" v-cloak> <q-layout view="hHh lpR lfr" v-cloak>
<lnbits-disclaimer></lnbits-disclaimer>
<lnbits-theme></lnbits-theme> <lnbits-theme></lnbits-theme>
<lnbits-header></lnbits-header> <lnbits-header></lnbits-header>
{% block drawer %} {% block drawer %}

View file

@ -10,6 +10,7 @@ include('components/admin/extensions.vue') %} {%
include('components/admin/assets-config.vue') %} {% include('components/admin/assets-config.vue') %} {%
include('components/admin/notifications.vue') %} {% include('components/admin/notifications.vue') %} {%
include('components/admin/server.vue') %} {% include('components/admin/server.vue') %} {%
include('components/lnbits-disclaimer.vue') %} {%
include('components/lnbits-footer.vue') %} {% include('components/lnbits-footer.vue') %} {%
include('components/lnbits-header.vue') %} {% include('components/lnbits-header.vue') %} {%
include('components/lnbits-header-wallets.vue') %} {% include('components/lnbits-header-wallets.vue') %} {%

View file

@ -0,0 +1,28 @@
<template id="lnbits-disclaimer">
<q-dialog v-model="showDisclaimer" position="top">
<q-card class="q-pa-lg">
<h6
class="q-my-md text-primary"
v-text="$t('disclaimer_dialog_title')"
></h6>
<p class="whitespace-pre-line" v-text="$t('disclaimer_dialog')"></p>
<div class="row q-mt-lg">
<q-btn
outline
color="grey"
type="a"
href="/account"
:label="$t('my_account')"
></q-btn>
<q-btn
v-close-popup
flat
color="grey"
class="q-ml-auto"
:label="$t('i_understand')"
@click="g.disclaimerShown = !g.disclaimerShown"
></q-btn>
</div>
</q-card>
</q-dialog>
</template>

View file

@ -126,6 +126,7 @@
"js/components/lnbits-home-logos.js", "js/components/lnbits-home-logos.js",
"js/components/lnbits-qrcode.js", "js/components/lnbits-qrcode.js",
"js/components/lnbits-qrcode-lnurl.js", "js/components/lnbits-qrcode-lnurl.js",
"js/components/lnbits-disclaimer.js",
"js/components/lnbits-footer.js", "js/components/lnbits-footer.js",
"js/components/lnbits-header.js", "js/components/lnbits-header.js",
"js/components/lnbits-header-wallets.js", "js/components/lnbits-header-wallets.js",