Skip to content

Commit

Permalink
Check user theme preference, closes umami-software#555.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Apr 26, 2021
1 parent 9270581 commit 041c773
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hooks/useTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { THEME_CONFIG } from 'lib/constants';
import { useEffect } from 'react';

export default function useTheme() {
const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || 'light');
const defaultTheme = window?.matchMedia('prefers-color-scheme: dark')?.matches ? 'dark' : 'light';
const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || defaultTheme);
const dispatch = useDispatch();

function saveTheme(value) {
Expand Down

0 comments on commit 041c773

Please sign in to comment.