]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Default to dark theme if requested by user
authorChocobozzz <me@florianbigard.com>
Tue, 11 May 2021 13:41:13 +0000 (15:41 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 11 May 2021 13:41:13 +0000 (15:41 +0200)
CHANGELOG.md
client/src/app/core/theme/theme.service.ts

index 6d9f098335f835302d6bb845c20a18d9cb834af5..a37ee604da3dc2a37fe971cf7a47a3b66eea8c61 100644 (file)
@@ -67,7 +67,7 @@
 
 ### Features
 
 
 ### Features
 
- * :tada: Most robust uploads using a resumable upload endpoint [#3933](https://github.com/Chocobozzz/PeerTube/pull/3933)
+ * :tada: More robust uploads using a resumable upload endpoint [#3933](https://github.com/Chocobozzz/PeerTube/pull/3933)
  * Accessibility/UI:
    * :tada: Redesign channel and account page
    * :tada: Increase video miniature size
  * Accessibility/UI:
    * :tada: Redesign channel and account page
    * :tada: Increase video miniature size
index 4c4611d01cab765ba0fbcb33050a20a44d021185..e7a5ae17a52d7e24867fae535e271817c49eb261 100644 (file)
@@ -82,7 +82,19 @@ export class ThemeService {
       : this.userService.getAnonymousUser().theme
 
     if (theme !== 'instance-default') return theme
       : this.userService.getAnonymousUser().theme
 
     if (theme !== 'instance-default') return theme
-    return this.serverConfig.theme.default
+
+    const instanceTheme = this.serverConfig.theme.default
+    if (instanceTheme !== 'default') return instanceTheme
+
+    // Default to dark theme if available and wanted by the user
+    if (
+      this.themes.find(t => t.name === 'dark') &&
+      window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
+    ) {
+      return 'dark'
+    }
+
+    return instanceTheme
   }
 
   private loadTheme (name: string) {
   }
 
   private loadTheme (name: string) {