Skip to content

Commit

Permalink
match dark theme of system if no nextcloud theme specified
Browse files Browse the repository at this point in the history
problem example:
a new user is created who uses system dark mode, so nextcloud will be in dark mode
but collabora would not be turned to dark mode as all the themes(ie:themeDark and themeDarkHighcontrast) value are undefined

Signed-off-by: Pranam Lashkari <[email protected]>
  • Loading branch information
lpranam authored and juliushaertl committed Mar 27, 2024
1 parent 5239327 commit 5826ae4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/helpers/coolParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const getUIDefaults = () => {
const textRuler = 'false'
const sidebar = 'false'
const saveAsMode = 'group'
const uiMode = defaults.UIMode ?? 'notebookbar' // or notebookbar
const uiMode = defaults.UIMode ?? 'notebookbar'

const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
// FIXME For now we need to access parent here as the public page loaded for collabora doesn't have the user theme
const nextcloudDarkMode = parent.document.body.dataset.themeDark === '' || parent.document.body.dataset.themeDarkHighcontrast === ''
const matchedDarkMode = parent.document.body.dataset.themeDefault === '' ? systemDarkMode : nextcloudDarkMode
const dataset = (document.body.dataset.themes ? document.body.dataset : parent?.document.body.dataset) ?? {}
const nextcloudDarkMode = dataset?.themeDark === '' || dataset?.themeDarkHighcontrast === ''
const matchedDarkMode = (!dataset?.themes || dataset?.themes === '' || dataset?.themeDefault === '') ? systemDarkMode : nextcloudDarkMode
const uiTheme = matchedDarkMode ? 'dark' : 'light'

let uiDefaults = 'TextRuler=' + textRuler + ';'
Expand Down

0 comments on commit 5826ae4

Please sign in to comment.