From ee92de0ff7fa0b1a7ea06c6f9dc2337b41339673 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sat, 3 Aug 2019 23:44:45 +0300 Subject: [PATCH] Fix changing theme color and properly sync settings. --- client/components/Windows/Settings.vue | 2 +- client/js/options.js | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/client/components/Windows/Settings.vue b/client/components/Windows/Settings.vue index 34bdd6ba..9faa0347 100644 --- a/client/components/Windows/Settings.vue +++ b/client/components/Windows/Settings.vue @@ -481,7 +481,7 @@ export default { value = event.target.value; } - this.options.updateSetting(name, value); + this.options.updateSetting(name, value, true); }, changePassword() { const allFields = new FormData(this.$refs.settingsForm); diff --git a/client/js/options.js b/client/js/options.js index 2a37455e..9e36137d 100644 --- a/client/js/options.js +++ b/client/js/options.js @@ -84,20 +84,18 @@ function updateDesktopNotificationStatus() { } function applySetting(name, value) { - if (name === "syncSettings" && value) { - $syncWarningOverride.hide(); - $forceSyncButton.hide(); - } else if (name === "theme") { + if (name === "theme") { const themeUrl = `themes/${value}.css`; if ($theme.attr("href") !== themeUrl) { $theme.attr("href", themeUrl); - - const newTheme = $settings.find("#theme-select option[value='" + value + "']"); + const newTheme = vueApp.serverConfiguration.themes.filter( + (theme) => theme.name === value + )[0]; let themeColor = defaultThemeColor; - if (newTheme.length > 0 && newTheme[0].dataset.themeColor) { - themeColor = newTheme[0].dataset.themeColor; + if (newTheme.themeColor) { + themeColor = newTheme.themeColor; } document.querySelector('meta[name="theme-color"]').content = themeColor; @@ -117,7 +115,7 @@ function settingSetEmit(name, value) { socket.emit("setting:set", {name, value}); } -// When sync is `true` the setting will also be send to the backend for syncing. +// When sync is `true` the setting will also be sent to the backend for syncing. function updateSetting(name, value, sync) { settings[name] = value; storage.set("settings", JSON.stringify(settings));