From 05e97f741eff54fee38e884cb23ab6c688bb2390 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 13 Jan 2021 23:19:37 -0500 Subject: [PATCH] Added feature where if no user and device dark mode enabled, enable dark mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Added: - feature where if no user and device dark mode enabled, enable dark mode --- app/javascript/gabsocial/containers/display.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/javascript/gabsocial/containers/display.js b/app/javascript/gabsocial/containers/display.js index 21cfa7b4..e3cd4847 100644 --- a/app/javascript/gabsocial/containers/display.js +++ b/app/javascript/gabsocial/containers/display.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' +import { me } from '../initial_state' import { FONT_SIZES, THEMES, @@ -22,6 +23,11 @@ class Display extends React.PureComponent { this.updateRadiusSmallDisabled(this.state.radiusSmallDisabled) this.updateRadiusCircleDisabled(this.state.radiusCircleDisabled) this.updateFontSizes(this.state.fontSize) + + // If no user logged in and dark mode enabled, set to muted + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches && !me) { + this.updateTheme('muted') + } } static getDerivedStateFromProps(nextProps, prevState) {