optimized theme loading so that it wouldn't wait until ALL themes are loaded to

select one by default
This commit is contained in:
Henry Jameson 2020-01-17 00:27:46 +02:00
parent 24a7a9bfd8
commit f77d675434
2 changed files with 53 additions and 37 deletions

View file

@ -96,9 +96,26 @@ export default {
created () {
const self = this
getThemes().then((themesComplete) => {
self.availableStyles = themesComplete
})
getThemes()
.then((promises) => {
return Promise.all(
Object.entries(promises)
.map(([k, v]) => v.then(res => [k, res]))
)
})
.then(themes => themes.reduce((acc, [k, v]) => {
if (v) {
return {
...acc,
[k]: v
}
} else {
return acc
}
}, {}))
.then((themesComplete) => {
self.availableStyles = themesComplete
})
},
mounted () {
this.normalizeLocalState(this.$store.getters.mergedConfig.customTheme)