fix: persist UI config

This commit is contained in:
Vlad Stan 2023-07-18 13:56:53 +03:00
parent 0d88f15221
commit 4a07f1423a
2 changed files with 8 additions and 6 deletions

View file

@ -39,7 +39,7 @@
</div> </div>
<div class="text-caption text-grey ellipsis-2-lines" style="min-height: 40px"> <div class="text-caption text-grey ellipsis-2-lines" style="min-height: 40px">
<p v-if="stall.description">{{ stall.description }}</p> <p>{{ stall.description || '' }}</p>
</div> </div>

View file

@ -138,7 +138,7 @@ const market = async () => {
LNbits.utils LNbits.utils
.confirmDialog('Do you want to import this market profile?') .confirmDialog('Do you want to import this market profile?')
.onOk(async () => { .onOk(async () => {
await this.checkMarketplaceNaddr(n) await this.checkMarketNaddr(n)
this.searchText = '' this.searchText = ''
}) })
} catch { } } catch { }
@ -235,7 +235,7 @@ const market = async () => {
const params = new URLSearchParams(window.location.search) const params = new URLSearchParams(window.location.search)
await this.checkMarketplaceNaddr(params.get('naddr')) await this.checkMarketNaddr(params.get('naddr'))
await this.handleQueryParams(params) await this.handleQueryParams(params)
@ -298,6 +298,9 @@ const market = async () => {
console.log('#### relays', relays, this.relays) console.log('#### relays', relays, this.relays)
}, },
applyUiConfigs(config = {}) { applyUiConfigs(config = {}) {
const { name, about, ui } = config?.opts || {}
console.log('### applyUiConfigs', name, about, ui)
this.$q.localStorage.set('nostrmarket.marketplaceConfig', { name, about, ui })
if (config.opts?.ui?.theme) { if (config.opts?.ui?.theme) {
document.body.setAttribute('data-theme', this.config.opts.ui.theme) document.body.setAttribute('data-theme', this.config.opts.ui.theme)
this.$q.localStorage.set('lnbits.theme', this.config.opts.ui.theme) this.$q.localStorage.set('lnbits.theme', this.config.opts.ui.theme)
@ -369,7 +372,6 @@ const market = async () => {
const { name, about, ui } = updateData const { name, about, ui } = updateData
this.config = { ...this.config, opts: { ...this.config.opts, name, about, ui } } this.config = { ...this.config, opts: { ...this.config.opts, name, about, ui } }
this.applyUiConfigs(this.config) this.applyUiConfigs(this.config)
this.$q.localStorage.set('nostrmarket.marketplaceConfig', { name, about, ui })
}, },
async updateData(events) { async updateData(events) {
@ -452,7 +454,7 @@ const market = async () => {
return return
}, },
async checkMarketplaceNaddr(naddr) { async checkMarketNaddr(naddr) {
if (!naddr) return if (!naddr) return
try { try {
@ -486,8 +488,8 @@ const market = async () => {
this.config = { ... this.config, opts: JSON.parse(event.content) } this.config = { ... this.config, opts: JSON.parse(event.content) }
this.addMerchants(this.config.opts?.merchants) this.addMerchants(this.config.opts?.merchants)
this.applyUiConfigs(this.config) this.applyUiConfigs(this.config)
} catch (error) { } catch (error) {
console.warn(error) console.warn(error)
} }