]> source.dussan.org Git - nextcloud-server.git/commitdiff
files: Fix colormode detection for filelist 33299/head
authorFerdinand Thiessen <rpm@fthiessen.de>
Wed, 20 Jul 2022 17:21:32 +0000 (19:21 +0200)
committerFerdinand Thiessen <rpm@fthiessen.de>
Tue, 26 Jul 2022 10:19:42 +0000 (12:19 +0200)
When system default color theme is selected for theming, the `enabledThemes` array
is empty or just contains on entry `'default'`, in this case the color theme has
to be retrieved from the browser to ensure text like the modified date is readable.

This fixes #33298

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
apps/files/js/filelist.js

index 42afe792142fc0dcbed351f1d35d608cec4c885d..d745f3368a5a7c270bc6a2e02f09fe9828e1ac1a 100644 (file)
                        td.append(linkElem);
                        tr.append(td);
 
-                       var enabledThemes = window.OCA?.Theming?.enabledThemes || []
-                       var isDarkTheme = enabledThemes.join('').indexOf('dark') !== -1
+                       const enabledThemes = window.OCA?.Theming?.enabledThemes || []
+                       // Check enabled themes, if system default is selected check the browser
+                       const isDarkTheme = (enabledThemes.length === 0 || enabledThemes[0] === 'default')
+                               ? window.matchMedia('(prefers-color-scheme: dark)').matches
+                               : enabledThemes.join('').indexOf('dark') !== -1
 
                        try {
                                var maxContrastHex = window.getComputedStyle(document.documentElement)