Skip to content

Commit

Permalink
dashboard: Fix dark theme detection
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
susnux committed Jul 20, 2022
1 parent de08b53 commit 1a20222
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/dashboard/src/helpers/getBackgroundUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import prefixWithBaseUrl from './prefixWithBaseUrl'

export default (background, time = 0, themingDefaultBackground = '') => {
const enabledThemes = window.OCA.Theming.enabledThemes
const isDarkTheme = enabledThemes.join('').indexOf('dark') !== -1
const isDarkTheme = enabledThemes && (enabledThemes.length > 1 || enabledThemes[0] !== 'default')
? enabledThemes.join('').indexOf('dark') !== -1
: window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches

if (background === 'default') {
if (themingDefaultBackground && themingDefaultBackground !== 'backgroundColor') {
Expand Down

0 comments on commit 1a20222

Please sign in to comment.