mirror of
https://github.com/bitwarden/web
synced 2025-12-10 21:33:16 +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:
@@ -19,7 +19,7 @@ export class OptionsComponent implements OnInit {
|
|||||||
disableIcons: boolean;
|
disableIcons: boolean;
|
||||||
enableGravatars: boolean;
|
enableGravatars: boolean;
|
||||||
enableFullWidth: boolean;
|
enableFullWidth: boolean;
|
||||||
theme: ThemeType = ThemeType.Light;
|
theme: ThemeType;
|
||||||
locale: string;
|
locale: string;
|
||||||
vaultTimeouts: { name: string; value: number }[];
|
vaultTimeouts: { name: string; value: number }[];
|
||||||
localeOptions: any[];
|
localeOptions: any[];
|
||||||
@@ -28,7 +28,7 @@ export class OptionsComponent implements OnInit {
|
|||||||
vaultTimeout: FormControl = new FormControl(null);
|
vaultTimeout: FormControl = new FormControl(null);
|
||||||
|
|
||||||
private startingLocale: string;
|
private startingLocale: string;
|
||||||
private startingTheme: ThemeType = ThemeType.Light;
|
private startingTheme: ThemeType;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
|
|||||||
13
src/theme.js
13
src/theme.js
@@ -6,17 +6,16 @@
|
|||||||
const htmlEl = document.documentElement;
|
const htmlEl = document.documentElement;
|
||||||
let theme = defaultTheme;
|
let theme = defaultTheme;
|
||||||
|
|
||||||
const stateJson = window.localStorage.getItem("state");
|
const globalState = window.localStorage.getItem("global");
|
||||||
if (stateJson != null) {
|
if (globalState != null) {
|
||||||
const globals = JSON.parse(stateJson).globals;
|
const globalStateJson = JSON.parse(globalState);
|
||||||
if (globals != null && globals.theme != null) {
|
if (globalStateJson != null && globalStateJson.theme != null) {
|
||||||
if (globals.theme.indexOf("system") > -1) {
|
if (globalStateJson.theme.indexOf("system") > -1) {
|
||||||
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
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";
|
theme = "dark";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!htmlEl.classList.contains("theme_" + theme)) {
|
if (!htmlEl.classList.contains("theme_" + theme)) {
|
||||||
htmlEl.classList.remove("theme_" + defaultTheme);
|
htmlEl.classList.remove("theme_" + defaultTheme);
|
||||||
htmlEl.classList.add("theme_" + theme);
|
htmlEl.classList.add("theme_" + theme);
|
||||||
|
|||||||
Reference in New Issue
Block a user