From bce88efa4f1a69a45ad83c61aac9110ec04a899a Mon Sep 17 00:00:00 2001
From: Germain <germain@grabyo.com>
Date: Sun, 21 Feb 2021 16:15:32 +0000
Subject: [PATCH] update isUserOnDarkTheme to return correct theme when
 use_system_theme is true

Signed-off-by: Germain <germain@grabyo.com>
---
 src/components/structures/UserMenu.tsx | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx
index 7f96e2d142..5ed6a00d74 100644
--- a/src/components/structures/UserMenu.tsx
+++ b/src/components/structures/UserMenu.tsx
@@ -103,11 +103,15 @@ export default class UserMenu extends React.Component<IProps, IState> {
     };
 
     private isUserOnDarkTheme(): boolean {
-        const theme = SettingsStore.getValue("theme");
-        if (theme.startsWith("custom-")) {
-            return getCustomTheme(theme.substring("custom-".length)).is_dark;
+        if (SettingsStore.getValue("use_system_theme")) {
+            return window.matchMedia("(prefers-color-scheme: dark)").matches;
+        } else {
+            const theme = SettingsStore.getValue("theme");
+            if (theme.startsWith("custom-")) {
+                return getCustomTheme(theme.substring("custom-".length)).is_dark;
+            }
+            return theme === "dark";
         }
-        return theme === "dark";
     }
 
     private onProfileUpdate = async () => {