fix: make night mode default for code blocks

This commit is contained in:
Oliver Eyton-Williams
2019-08-23 14:36:31 +02:00
committed by mrugesh
parent 07b73e2860
commit 5a38887af1

View File

@ -2,12 +2,13 @@
import { takeEvery } from 'redux-saga/effects'; import { takeEvery } from 'redux-saga/effects';
import store from 'store'; import store from 'store';
import { isEmpty } from 'lodash';
const themeKey = 'fcc-theme'; const themeKey = 'fcc-theme';
const defaultTheme = 'default'; const defaultTheme = 'default';
const nightTheme = 'night'; const nightTheme = 'night';
function setTheme(currentTheme = defaultTheme, theme) { function setTheme(currentTheme = nightTheme, theme = nightTheme) {
if (currentTheme !== theme) { if (currentTheme !== theme) {
store.set(themeKey, theme); store.set(themeKey, theme);
} }
@ -17,9 +18,9 @@ function setTheme(currentTheme = defaultTheme, theme) {
} }
function* updateLocalThemeSaga({ payload: { user, theme } }) { function* updateLocalThemeSaga({ payload: { user, theme } }) {
const currentTheme = store.get(themeKey) || defaultTheme; const currentTheme = store.get(themeKey) || nightTheme;
if (user) { if (!isEmpty(user)) {
const { theme = defaultTheme } = user; const { theme = nightTheme } = user;
return setTheme(currentTheme, theme); return setTheme(currentTheme, theme);
} }
if (theme) { if (theme) {