diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-11 15:41:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-11 15:41:13 +0200 |
commit | 5c48aa8c3ef48369235bc3a222bbbe5e08c6bd93 (patch) | |
tree | 41391149eda62d5b48a8c6c644c479db250c200e /client | |
parent | 3914a50b0732076707a6e4e22f54254ae00fc829 (diff) | |
download | PeerTube-5c48aa8c3ef48369235bc3a222bbbe5e08c6bd93.tar.gz PeerTube-5c48aa8c3ef48369235bc3a222bbbe5e08c6bd93.tar.zst PeerTube-5c48aa8c3ef48369235bc3a222bbbe5e08c6bd93.zip |
Default to dark theme if requested by user
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/core/theme/theme.service.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.ts index 4c4611d01..e7a5ae17a 100644 --- a/client/src/app/core/theme/theme.service.ts +++ b/client/src/app/core/theme/theme.service.ts | |||
@@ -82,7 +82,19 @@ export class ThemeService { | |||
82 | : this.userService.getAnonymousUser().theme | 82 | : this.userService.getAnonymousUser().theme |
83 | 83 | ||
84 | if (theme !== 'instance-default') return theme | 84 | if (theme !== 'instance-default') return theme |
85 | return this.serverConfig.theme.default | 85 | |
86 | const instanceTheme = this.serverConfig.theme.default | ||
87 | if (instanceTheme !== 'default') return instanceTheme | ||
88 | |||
89 | // Default to dark theme if available and wanted by the user | ||
90 | if ( | ||
91 | this.themes.find(t => t.name === 'dark') && | ||
92 | window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | ||
93 | ) { | ||
94 | return 'dark' | ||
95 | } | ||
96 | |||
97 | return instanceTheme | ||
86 | } | 98 | } |
87 | 99 | ||
88 | private loadTheme (name: string) { | 100 | private loadTheme (name: string) { |