From 62fb5524aef9b43b965ed2dfa100a3b369c1a7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 2 Apr 2018 00:25:45 -0400 Subject: [PATCH] Switch client to default theme when it is using a theme that has been removed --- client/js/options.js | 2 +- client/js/socket-events/configuration.js | 6 ++++++ src/server.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/js/options.js b/client/js/options.js index b4eaaaa1..f741fbd3 100644 --- a/client/js/options.js +++ b/client/js/options.js @@ -281,7 +281,7 @@ function initialize() { } $settings.on("change", "input, select, textarea", function(e) { - // We only want to trigger on human triggerd changes. + // We only want to trigger on human triggered changes. if (e.originalEvent) { const $self = $(this); const type = $self.prop("type"); diff --git a/client/js/socket-events/configuration.js b/client/js/socket-events/configuration.js index 2a6fec17..1a7bf32c 100644 --- a/client/js/socket-events/configuration.js +++ b/client/js/socket-events/configuration.js @@ -25,6 +25,12 @@ socket.on("configuration", function(data) { options.initialize(); webpush.initialize(); + // If localStorage contains a theme that does not exist on this server, switch + // back to its default theme. + if (!data.themes.map((t) => t.name).includes(options.settings.theme)) { + options.processSetting("theme", data.defaultTheme, true); + } + const forms = $("#connect form, #change-password form"); forms.on("submit", function() { diff --git a/src/server.js b/src/server.js index af04d8c4..0971fb9c 100644 --- a/src/server.js +++ b/src/server.js @@ -555,6 +555,7 @@ function getClientConfiguration() { config.version = pkg.version; config.gitCommit = Helper.getGitCommit(); config.themes = themes.getAll(); + config.defaultTheme = Helper.config.theme; if (config.displayNetwork) { config.defaults = _.clone(Helper.config.defaults);