Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e30a0d6

Browse files
authored
Merge pull request #5670 from gsouquet/fix/is-on-dark-theme
Update isUserOnDarkTheme to take use_system_theme in account
2 parents a794bfd + bce88ef commit e30a0d6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/structures/UserMenu.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ export default class UserMenu extends React.Component<IProps, IState> {
103103
};
104104

105105
private isUserOnDarkTheme(): boolean {
106-
const theme = SettingsStore.getValue("theme");
107-
if (theme.startsWith("custom-")) {
108-
return getCustomTheme(theme.substring("custom-".length)).is_dark;
106+
if (SettingsStore.getValue("use_system_theme")) {
107+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
108+
} else {
109+
const theme = SettingsStore.getValue("theme");
110+
if (theme.startsWith("custom-")) {
111+
return getCustomTheme(theme.substring("custom-".length)).is_dark;
112+
}
113+
return theme === "dark";
109114
}
110-
return theme === "dark";
111115
}
112116

113117
private onProfileUpdate = async () => {

0 commit comments

Comments
 (0)