Fix changing theme color and properly sync settings.

This commit is contained in:
Richard Lewis 2019-08-03 23:44:45 +03:00 committed by Pavel Djundik
parent b5f2e7f0cc
commit ee92de0ff7
2 changed files with 8 additions and 10 deletions

View File

@ -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);

View File

@ -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));