1
0
mirror of https://github.com/bitwarden/web synced 2026-01-14 22:43:14 +00:00

[bug] Update theme.js to refelect new storage structure (#1416)

* [bug] Update theme.js to refelect new storage structure

* [bug] Remove unecassary defaults
This commit is contained in:
Addison Beck
2022-01-28 11:30:45 -05:00
committed by GitHub
parent 6996b06fa2
commit ce1ae208d1
2 changed files with 8 additions and 9 deletions

View File

@@ -6,17 +6,16 @@
const htmlEl = document.documentElement;
let theme = defaultTheme;
const stateJson = window.localStorage.getItem("state");
if (stateJson != null) {
const globals = JSON.parse(stateJson).globals;
if (globals != null && globals.theme != null) {
if (globals.theme.indexOf("system") > -1) {
const globalState = window.localStorage.getItem("global");
if (globalState != null) {
const globalStateJson = JSON.parse(globalState);
if (globalStateJson != null && globalStateJson.theme != null) {
if (globalStateJson.theme.indexOf("system") > -1) {
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
} else if (globals.theme.indexOf("dark") > -1) {
} else if (globalStateJson.theme.indexOf("dark") > -1) {
theme = "dark";
}
}
if (!htmlEl.classList.contains("theme_" + theme)) {
htmlEl.classList.remove("theme_" + defaultTheme);
htmlEl.classList.add("theme_" + theme);