fix: dark mode

This commit is contained in:
Vlad Stan 2023-07-18 10:01:52 +03:00
parent d8721a0785
commit c366d571ef
2 changed files with 15 additions and 6 deletions

View file

@ -89,10 +89,12 @@ async function marketConfig(path) {
}
},
created: async function () {
console.log('### this.configData', this.configData)
console.log('### this.configUi', this.configUi)
if (this.configUi) {
this.configData = { ...this.configData, ...this.configUi }
this.configData = { ...this.configData, ...this.configUi, ui: { ...this.configData.ui, ...(this.configUi.ui || {}) } }
}
console.log('### this.configData', this.configData)
}
})

View file

@ -188,9 +188,7 @@ const market = async () => {
isValidAccountKey() {
return isValidKey(this.accountDialog.data.key)
},
canEditConfig() {
return this.account && this.account.pubkey == this.config?.pubkey
},
allCartsItemCount() {
return this.shoppingCarts.map(s => s.products).flat().reduce((t, p) => t + p.orderedQuantity, 0)
@ -278,8 +276,10 @@ const market = async () => {
this.account = this.$q.localStorage.getItem('nostrmarket.account') || null
const uiConfig = this.$q.localStorage.getItem('nostrmarket.marketplace-config') || {}
console.log('### uiConfig storage: ', uiConfig)
// trigger the `watch` logic
this.config = { ...this.config, opts: { ...this.config.opts, ...uiConfig } }
console.log('#### restoreFromStorage this.config', this.config)
this.applyUiConfigs(this.config)
@ -297,9 +297,16 @@ const market = async () => {
applyUiConfigs(config = {}) {
if (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)
}
if (config.opts?.ui?.darkMode) {
// tood
const newDarkMode = config.opts?.ui?.darkMode
if (newDarkMode !== undefined) {
const oldDarkMode = this.$q.localStorage.getItem('lnbits.darkMode')
if (newDarkMode !== oldDarkMode) {
this.$q.dark.toggle()
this.$q.localStorage.set('lnbits.darkMode', newDarkMode)
}
}
},