refactor: extract applyUiConfigs
This commit is contained in:
parent
6c3f2b529b
commit
d8721a0785
1 changed files with 13 additions and 14 deletions
|
|
@ -280,12 +280,8 @@ const market = async () => {
|
|||
const uiConfig = this.$q.localStorage.getItem('nostrmarket.marketplace-config') || {}
|
||||
// trigger the `watch` logic
|
||||
this.config = { ...this.config, opts: { ...this.config.opts, ...uiConfig } }
|
||||
if (this.config?.opts?.ui?.theme) {
|
||||
document.body.setAttribute('data-theme', this.config.opts.ui.theme)
|
||||
}
|
||||
this.applyUiConfigs(this.config)
|
||||
|
||||
console.log('### uiConfig', uiConfig)
|
||||
console.log('### this.config', this.config)
|
||||
|
||||
const prefix = 'nostrmarket.orders.'
|
||||
const orderKeys = this.$q.localStorage.getAllKeys().filter(k => k.startsWith(prefix))
|
||||
|
|
@ -296,8 +292,17 @@ const market = async () => {
|
|||
|
||||
const relays = this.$q.localStorage.getItem('nostrmarket.relays')
|
||||
this.relays = new Set(relays?.length ? relays : defaultRelays)
|
||||
|
||||
console.log('#### relays', relays, this.relays)
|
||||
},
|
||||
applyUiConfigs(config = {}) {
|
||||
if (config.opts?.ui?.theme) {
|
||||
document.body.setAttribute('data-theme', this.config.opts.ui.theme)
|
||||
}
|
||||
if (config.opts?.ui?.darkMode) {
|
||||
// tood
|
||||
}
|
||||
},
|
||||
|
||||
async deleteAccount() {
|
||||
await LNbits.utils
|
||||
.confirmDialog(
|
||||
|
|
@ -353,14 +358,10 @@ const market = async () => {
|
|||
console.log('### updateUiConfig', updateData)
|
||||
const { name, about, ui } = updateData
|
||||
this.config.opts = { ...this.config.opts, name, about, ui }
|
||||
if (ui.theme) {
|
||||
document.body.setAttribute('data-theme', ui.theme)
|
||||
}
|
||||
this.applyUiConfigs(this.config)
|
||||
this.$q.localStorage.set('nostrmarket.marketplace-config', { name, about, ui })
|
||||
|
||||
|
||||
|
||||
|
||||
if (!this.account?.privkey) return
|
||||
|
||||
const merchants = Array.from(this.merchants.map(m => m.publicKey))
|
||||
|
|
@ -508,9 +509,7 @@ const market = async () => {
|
|||
.map(m => ({ publicKey: m, profile: null }))
|
||||
this.merchants.push(...extraMerchants)
|
||||
|
||||
// change theme
|
||||
const { theme } = this.config.opts?.ui
|
||||
theme && document.body.setAttribute('data-theme', theme)
|
||||
this.applyUiConfigs(this.config)
|
||||
} catch (error) {
|
||||
console.warn(error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue