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') || {}
|
const uiConfig = this.$q.localStorage.getItem('nostrmarket.marketplace-config') || {}
|
||||||
// trigger the `watch` logic
|
// trigger the `watch` logic
|
||||||
this.config = { ...this.config, opts: { ...this.config.opts, ...uiConfig } }
|
this.config = { ...this.config, opts: { ...this.config.opts, ...uiConfig } }
|
||||||
if (this.config?.opts?.ui?.theme) {
|
this.applyUiConfigs(this.config)
|
||||||
document.body.setAttribute('data-theme', this.config.opts.ui.theme)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('### uiConfig', uiConfig)
|
|
||||||
console.log('### this.config', this.config)
|
|
||||||
|
|
||||||
const prefix = 'nostrmarket.orders.'
|
const prefix = 'nostrmarket.orders.'
|
||||||
const orderKeys = this.$q.localStorage.getAllKeys().filter(k => k.startsWith(prefix))
|
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')
|
const relays = this.$q.localStorage.getItem('nostrmarket.relays')
|
||||||
this.relays = new Set(relays?.length ? relays : defaultRelays)
|
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() {
|
async deleteAccount() {
|
||||||
await LNbits.utils
|
await LNbits.utils
|
||||||
.confirmDialog(
|
.confirmDialog(
|
||||||
|
|
@ -353,14 +358,10 @@ const market = async () => {
|
||||||
console.log('### updateUiConfig', updateData)
|
console.log('### updateUiConfig', updateData)
|
||||||
const { name, about, ui } = updateData
|
const { name, about, ui } = updateData
|
||||||
this.config.opts = { ...this.config.opts, name, about, ui }
|
this.config.opts = { ...this.config.opts, name, about, ui }
|
||||||
if (ui.theme) {
|
this.applyUiConfigs(this.config)
|
||||||
document.body.setAttribute('data-theme', ui.theme)
|
|
||||||
}
|
|
||||||
this.$q.localStorage.set('nostrmarket.marketplace-config', { name, about, ui })
|
this.$q.localStorage.set('nostrmarket.marketplace-config', { name, about, ui })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!this.account?.privkey) return
|
if (!this.account?.privkey) return
|
||||||
|
|
||||||
const merchants = Array.from(this.merchants.map(m => m.publicKey))
|
const merchants = Array.from(this.merchants.map(m => m.publicKey))
|
||||||
|
|
@ -508,9 +509,7 @@ const market = async () => {
|
||||||
.map(m => ({ publicKey: m, profile: null }))
|
.map(m => ({ publicKey: m, profile: null }))
|
||||||
this.merchants.push(...extraMerchants)
|
this.merchants.push(...extraMerchants)
|
||||||
|
|
||||||
// change theme
|
this.applyUiConfigs(this.config)
|
||||||
const { theme } = this.config.opts?.ui
|
|
||||||
theme && document.body.setAttribute('data-theme', theme)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue