From 203bded1e75b218fff82d3f0b3da87e30015e647 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 24 Sep 2021 17:12:58 +0300 Subject: [PATCH] [all] fix old-style loader (#1205) --- apps/common/main/lib/controller/Themes.js | 9 +++- apps/common/main/lib/util/htmlutils.js | 6 +-- apps/documenteditor/main/index_loader.html | 45 ++++++++++------- .../main/index_loader.html.deploy | 49 ++++++++++++------- .../presentationeditor/main/index_loader.html | 46 ++++++++++------- .../main/index_loader.html.deploy | 49 ++++++++++++------- apps/spreadsheeteditor/main/index_loader.html | 47 +++++++++++------- .../main/index_loader.html.deploy | 49 ++++++++++++------- 8 files changed, 188 insertions(+), 112 deletions(-) diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 4f964cd70..f52e28893 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -232,7 +232,14 @@ define([ !classname.startsWith('theme-type-') && themes_map[classname] ) { theme_name = classname; - Common.localStorage.setItem('ui-theme-id', theme_name); + // Common.localStorage.setItem('ui-theme-id', theme_name); + var theme_obj = { + id: theme_name, + type: themes_map[theme_name].type, + }; + + Common.localStorage.setItem('ui-theme', JSON.stringify(theme_obj)); + } }); } diff --git a/apps/common/main/lib/util/htmlutils.js b/apps/common/main/lib/util/htmlutils.js index 5b511ce8f..a910a6922 100644 --- a/apps/common/main/lib/util/htmlutils.js +++ b/apps/common/main/lib/util/htmlutils.js @@ -61,14 +61,14 @@ if ( !!params.uitheme && checkLocalStorage && !localStorage.getItem("ui-theme-id if ( params.uitheme == 'default-light' ) params.uitheme = 'theme-classic-light'; - localStorage.setItem("ui-theme-id", params.uitheme); + localStorage.removeItem("ui-theme"); } -var ui_theme_name = checkLocalStorage ? localStorage.getItem("ui-theme-id") : undefined; +var ui_theme_name = checkLocalStorage && localStorage.getItem("ui-theme-id") ? localStorage.getItem("ui-theme-id") : params.uitheme; if ( !ui_theme_name ) { if ( window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ) { ui_theme_name = 'theme-dark'; - checkLocalStorage && localStorage.setItem("ui-theme-id", ui_theme_name); + checkLocalStorage && localStorage.removeItem("ui-theme"); } } if ( !!ui_theme_name ) { diff --git a/apps/documenteditor/main/index_loader.html b/apps/documenteditor/main/index_loader.html index ec8d05340..29cd5630c 100644 --- a/apps/documenteditor/main/index_loader.html +++ b/apps/documenteditor/main/index_loader.html @@ -10,6 +10,10 @@