Skip to content

Commit a8975e7

Browse files
getSystemTheme
1 parent e1d56cc commit a8975e7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.env

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ NAVIGATION_SIDEBAR_HIDDEN=false
5252

5353
# Limit items rows on emojiboard.
5454
FAV_EMOJI_ROWS_LIMIT=50
55-
5655
RECENT_EMOJI_ROWS_LIMIT=3
57-
5856
FAV_STICKER_ROWS_LIMIT=3
59-
6057
RECENT_STICKER_ROWS_LIMIT=50
6158

6259
### Homeserver list

src/client/state/settings.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class Settings extends EventEmitter {
115115
},
116116
);
117117

118+
this.systemIsDark = null;
118119
this.useSystemTheme = this.getUseSystemTheme();
119120
this.isMarkdown = this.getIsMarkdown();
120121
this.isPeopleDrawer = this.getIsPeopleDrawer();
@@ -128,6 +129,13 @@ class Settings extends EventEmitter {
128129
'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
129130
}
130131

132+
getSystemTheme() {
133+
return {
134+
enabled: this.useSystemTheme,
135+
isDark: this.systemIsDark,
136+
};
137+
}
138+
131139
getThemeIndex() {
132140
if (typeof this.themeIndex === 'number') return this.themeIndex;
133141

@@ -246,10 +254,12 @@ class Settings extends EventEmitter {
246254
body.addClass('discord-style');
247255
}
248256

257+
this.systemIsDark =
258+
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
249259
if (useSystemTheme) {
250260
body.addClass('system-theme');
251261

252-
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
262+
if (this.systemIsDark) {
253263
body.addClass(this.defaultSystemThemeType.dark);
254264
} else {
255265
body.addClass(this.defaultSystemThemeType.light);

0 commit comments

Comments
 (0)