From 06deb0f09ddf2afd842e5055107361453634601c Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 11 Jul 2022 23:57:29 +0300 Subject: [PATCH] [themes] fix theme flashing when multiple editors open --- apps/common/main/lib/controller/Themes.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 732e497a0a..7ed8051ad5 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -413,10 +413,11 @@ define([ Common.NotificationCenter.trigger('contenttheme:dark', !is_current_dark); }, - setTheme: function (obj, force) { + setTheme: function (obj) { if ( !obj ) return; - var id = get_ui_theme_name(obj); + var id = get_ui_theme_name(obj), + refresh_only = arguments[1]; if ( is_theme_type_system(id) ) { Common.localStorage.setBool('ui-theme-use-system', true); @@ -425,7 +426,7 @@ define([ Common.localStorage.setBool('ui-theme-use-system', false); } - if ( (this.currentThemeId() != id || force) && !!themes_map[id] ) { + if ( (this.currentThemeId() != id || refresh_only) && !!themes_map[id] ) { document.body.className = document.body.className.replace(/theme-[\w-]+\s?/gi, '').trim(); document.body.classList.add(id, 'theme-type-' + themes_map[id].type); @@ -456,10 +457,12 @@ define([ theme_obj.colors = obj; } - Common.localStorage.setItem('ui-theme', JSON.stringify(theme_obj)); + if ( !refresh_only ) + Common.localStorage.setItem('ui-theme', JSON.stringify(theme_obj)); } - Common.localStorage.setItem('ui-theme-id', id); + if ( !refresh_only ) + Common.localStorage.setItem('ui-theme-id', id); Common.NotificationCenter.trigger('uitheme:changed', id); } },