dashboard: Fix dark theme detection

When system default color theme is selected for theming,
the enabledThemes array is empty or just contains one entry 'default',
in this case the color theme has to be retrieved from the browser.

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
pull/33300/head
Ferdinand Thiessen 2022-07-20 21:11:57 +07:00 committed by nextcloud-command
parent 7615536977
commit 800f6b350e
3 changed files with 7 additions and 5 deletions

@ -26,8 +26,10 @@ import { generateUrl } from '@nextcloud/router'
import prefixWithBaseUrl from './prefixWithBaseUrl'
export default (background, time = 0, themingDefaultBackground = '') => {
const enabledThemes = window.OCA.Theming.enabledThemes
const isDarkTheme = enabledThemes.join('').indexOf('dark') !== -1
const enabledThemes = window.OCA?.Theming?.enabledThemes || []
const isDarkTheme = (enabledThemes.length === 0 || enabledThemes[0] === 'default')
? window.matchMedia('(prefers-color-scheme: dark)').matches
: enabledThemes.join('').indexOf('dark') !== -1
if (background === 'default') {
if (themingDefaultBackground && themingDefaultBackground !== 'backgroundColor') {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long