diff --git a/src/components/Settings/ThemeSelector.vue b/src/components/Settings/ThemeSelector.vue
index 7cceb2f6..5c1b7501 100644
--- a/src/components/Settings/ThemeSelector.vue
+++ b/src/components/Settings/ThemeSelector.vue
@@ -5,8 +5,10 @@
{
+ availibleThemes[`External Stylesheet ${i + 1}`] = ext;
+ });
+ } else {
+ availibleThemes['External Stylesheet'] = this.appConfig.externalStyleSheet;
+ }
+ }
+ }
+ availibleThemes.Default = '#';
+ return availibleThemes;
},
},
- created() {
+ mounted() {
+ const initialTheme = this.getInitialTheme();
+ this.selectedTheme = initialTheme;
// Pass all user custom stylesheets to the themehelper
const added = Object.keys(this.externalThemes).map(
name => this.themeHelper.add(name, this.externalThemes[name]),
);
// Quicker loading, if the theme is local we can apply it immidiatley
- if (this.isThemeLocal(this.selectedTheme)) {
- this.updateTheme(this.selectedTheme);
+ if (this.isThemeLocal(initialTheme)) {
+ this.updateTheme(initialTheme);
// If it's an external stylesheet, then wait for promise to resolve
- } else if (this.selectedTheme !== Defaults.theme) {
+ } else if (initialTheme !== Defaults.theme) {
Promise.all(added).then(() => {
- this.updateTheme(this.selectedTheme);
+ this.updateTheme(initialTheme);
});
}
},
methods: {
- /* Get default theme */
+ /* Called when dropdown changed
+ * Updates store, which will in turn update theme through watcher
+ */
+ themeChanged() {
+ this.$store.commit(Keys.SET_THEME, this.selectedTheme);
+ },
+ /* Returns the initial theme */
getInitialTheme() {
- return localStorage[localStorageKeys.THEME] || this.confTheme || Defaults.theme;
+ const localTheme = localStorage[localStorageKeys.THEME];
+ if (localTheme && localTheme !== 'undefined') return localTheme;
+ return this.confTheme || Defaults.theme;
},
/* Determines if a given theme is local / not a custom user stylesheet */
isThemeLocal(themeToCheck) {
- return this.builtInThemes.includes(themeToCheck);
+ const localThemes = [...Defaults.builtInThemes, ...this.extraThemeNames];
+ return localThemes.includes(themeToCheck);
},
/* Opens the theme color configurator popup */
openThemeConfigurator() {