yet another massive overhaul on how themes are loaded/applied

This commit is contained in:
Henry Jameson 2024-10-02 02:35:52 +03:00
commit ba4be2cb22
7 changed files with 381 additions and 259 deletions

View file

@ -4,9 +4,6 @@ import {
getContrastRatioLayers,
relativeLuminance
} from 'src/services/color_convert/color_convert.js'
import {
getThemeResources
} from 'src/services/style_setter/style_setter.js'
import {
newImporter,
newExporter
@ -123,12 +120,22 @@ export default {
}
},
created () {
const self = this
const currentIndex = this.$store.state.instance.themesIndex
getThemeResources('/static/styles.json')
.then((themesComplete) => {
self.availableStyles = Object.values(themesComplete)
})
let promise
if (currentIndex) {
promise = Promise.resolve(currentIndex)
} else {
promise = this.$store.dispatch('fetchThemesIndex')
}
promise.then(themesIndex => {
Object
.values(themesIndex)
.forEach(themeFunc => {
themeFunc().then(themeData => this.availableStyles.push(themeData))
})
})
},
mounted () {
this.loadThemeFromLocalStorage()