fix(fe/theme): enable theme immediately if auto theme is enabled
This commit is contained in:
parent
20b7cdaa7f
commit
3b42272d53
2 changed files with 16 additions and 9 deletions
|
@ -80,10 +80,14 @@ export class RootFrame extends React.Component<Props, State, {}> {
|
|||
|
||||
render() {
|
||||
const bgStyle = this.makeBgStyle();
|
||||
const theme =
|
||||
const autoTheme =
|
||||
updater().getCurrentTheme() === "light" ? "theme-default" : "theme-dark";
|
||||
const fixedTheme =
|
||||
this.props.login.preferences.theme === "light"
|
||||
? "theme-default"
|
||||
: "theme-dark";
|
||||
const theme = this.props.ui.clientCfg.autoTheme ? autoTheme : fixedTheme;
|
||||
|
||||
const fontSizeClass = "font-m";
|
||||
|
||||
const displaying = this.props.ui.control.controls.get(controlName);
|
||||
|
|
|
@ -789,20 +789,23 @@ export class Updater {
|
|||
this.props.login.preferences.theme = theme;
|
||||
};
|
||||
|
||||
autoSwitchTheme = () => {
|
||||
if (!this.props.ui.clientCfg.autoTheme) {
|
||||
return;
|
||||
}
|
||||
|
||||
getCurrentTheme = () => {
|
||||
const date = new Date();
|
||||
|
||||
if (
|
||||
(date.getHours() >= 18 && date.getHours() <= 23) ||
|
||||
(date.getHours() >= 0 && date.getHours() <= 6)
|
||||
) {
|
||||
this.setTheme("dark");
|
||||
} else {
|
||||
this.setTheme("light");
|
||||
return "dark";
|
||||
}
|
||||
return "light";
|
||||
};
|
||||
|
||||
autoSwitchTheme = () => {
|
||||
if (!this.props.ui.clientCfg.autoTheme) {
|
||||
return;
|
||||
}
|
||||
this.setTheme(this.getCurrentTheme());
|
||||
};
|
||||
|
||||
setControlOption = (controlName: string, option: string): boolean => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue