Merge pull request #4023 from matrix-org/dbkr/honor_islogin_system_theme
Honour the isLogin flag in theme.js
This commit is contained in:
commit
8b0e8571be
1 changed files with 16 additions and 1 deletions
17
src/theme.js
17
src/theme.js
|
@ -21,6 +21,7 @@ export const DEFAULT_THEME = "light";
|
||||||
import Tinter from "./Tinter";
|
import Tinter from "./Tinter";
|
||||||
import dis from "./dispatcher";
|
import dis from "./dispatcher";
|
||||||
import SettingsStore, {SettingLevel} from "./settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "./settings/SettingsStore";
|
||||||
|
import ThemeController from "./settings/controllers/ThemeController";
|
||||||
|
|
||||||
export class ThemeWatcher {
|
export class ThemeWatcher {
|
||||||
static _instance = null;
|
static _instance = null;
|
||||||
|
@ -82,12 +83,22 @@ export class ThemeWatcher {
|
||||||
getEffectiveTheme() {
|
getEffectiveTheme() {
|
||||||
// Dev note: Much of this logic is replicated in the GeneralUserSettingsTab
|
// Dev note: Much of this logic is replicated in the GeneralUserSettingsTab
|
||||||
|
|
||||||
|
// XXX: checking the isLight flag here makes checking it in the ThemeController
|
||||||
|
// itself completely redundant since we just override the result here and we're
|
||||||
|
// now effectively just using the ThemeController as a place to store the static
|
||||||
|
// variable. The system theme setting probably ought to have an equivalent
|
||||||
|
// controller that honours the same flag, although probablt better would be to
|
||||||
|
// have the theme logic in one place rather than split between however many
|
||||||
|
// different places.
|
||||||
|
if (ThemeController.isLogin) return 'light';
|
||||||
|
|
||||||
// If the user has specifically enabled the system matching option (excluding default),
|
// If the user has specifically enabled the system matching option (excluding default),
|
||||||
// then use that over anything else. We pick the lowest possible level for the setting
|
// then use that over anything else. We pick the lowest possible level for the setting
|
||||||
// to ensure the ordering otherwise works.
|
// to ensure the ordering otherwise works.
|
||||||
const systemThemeExplicit = SettingsStore.getValueAt(
|
const systemThemeExplicit = SettingsStore.getValueAt(
|
||||||
SettingLevel.DEVICE, "use_system_theme", null, false, true);
|
SettingLevel.DEVICE, "use_system_theme", null, false, true);
|
||||||
if (systemThemeExplicit) {
|
if (systemThemeExplicit) {
|
||||||
|
console.log("returning explicit system theme");
|
||||||
if (this._preferDark.matches) return 'dark';
|
if (this._preferDark.matches) return 'dark';
|
||||||
if (this._preferLight.matches) return 'light';
|
if (this._preferLight.matches) return 'light';
|
||||||
}
|
}
|
||||||
|
@ -97,7 +108,10 @@ export class ThemeWatcher {
|
||||||
// level for the setting to ensure the ordering otherwise works.
|
// level for the setting to ensure the ordering otherwise works.
|
||||||
const themeExplicit = SettingsStore.getValueAt(
|
const themeExplicit = SettingsStore.getValueAt(
|
||||||
SettingLevel.DEVICE, "theme", null, false, true);
|
SettingLevel.DEVICE, "theme", null, false, true);
|
||||||
if (themeExplicit) return themeExplicit;
|
if (themeExplicit) {
|
||||||
|
console.log("returning explicit theme: " + themeExplicit);
|
||||||
|
return themeExplicit;
|
||||||
|
}
|
||||||
|
|
||||||
// If the user hasn't really made a preference in either direction, assume the defaults of the
|
// If the user hasn't really made a preference in either direction, assume the defaults of the
|
||||||
// settings and use those.
|
// settings and use those.
|
||||||
|
@ -105,6 +119,7 @@ export class ThemeWatcher {
|
||||||
if (this._preferDark.matches) return 'dark';
|
if (this._preferDark.matches) return 'dark';
|
||||||
if (this._preferLight.matches) return 'light';
|
if (this._preferLight.matches) return 'light';
|
||||||
}
|
}
|
||||||
|
console.log("returning theme value");
|
||||||
return SettingsStore.getValue('theme');
|
return SettingsStore.getValue('theme');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue