diff options
| author | Henry Jameson <me@hjkos.com> | 2020-01-17 00:27:46 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2020-01-17 00:27:46 +0200 |
| commit | f77d675434ad7238e36e712ed69d01bc3233b156 (patch) | |
| tree | 6b45d142b0a9e62b8658bb90391250250a003f10 /src/components/style_switcher/style_switcher.js | |
| parent | 24a7a9bfd8dbdaae8b5a2e5dde5cb754a122905b (diff) | |
optimized theme loading so that it wouldn't wait until ALL themes are loaded to
select one by default
Diffstat (limited to 'src/components/style_switcher/style_switcher.js')
| -rw-r--r-- | src/components/style_switcher/style_switcher.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index 03cbb2a1..52ece3a1 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -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) |
