From 5c48aa8c3ef48369235bc3a222bbbe5e08c6bd93 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 May 2021 15:41:13 +0200 Subject: Default to dark theme if requested by user --- client/src/app/core/theme/theme.service.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'client/src/app') 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 { : 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) { -- cgit v1.2.3