From e209582daf9ea1c241ea777416def49f486d89db Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 13 Oct 2021 11:00:00 +0200 Subject: [PATCH] chore: remove night-mode-saga (#43829) The saga only sets the value of fcc-theme in storage, but the values are never retrieved, so the saga can be removed. --- client/src/redux/index.js | 4 +--- client/src/redux/night-mode-saga.js | 32 ----------------------------- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 client/src/redux/night-mode-saga.js diff --git a/client/src/redux/index.js b/client/src/redux/index.js index 857b5bcd90..4f67d97aaf 100644 --- a/client/src/redux/index.js +++ b/client/src/redux/index.js @@ -13,7 +13,6 @@ import { createFetchUserSaga } from './fetch-user-saga'; import { createGaSaga } from './ga-saga'; import hardGoToEpic from './hard-go-to-epic'; -import { createNightModeSaga } from './night-mode-saga'; import { createReportUserSaga } from './report-user-saga'; import { actionTypes as settingsTypes } from './settings/action-types'; @@ -75,8 +74,7 @@ export const sagas = [ ...createGaSaga(actionTypes), ...createFetchUserSaga(actionTypes), ...createShowCertSaga(actionTypes), - ...createReportUserSaga(actionTypes), - ...createNightModeSaga({ ...actionTypes, ...settingsTypes }) + ...createReportUserSaga(actionTypes) ]; export const appMount = createAction(actionTypes.appMount); diff --git a/client/src/redux/night-mode-saga.js b/client/src/redux/night-mode-saga.js deleted file mode 100644 index 038145d600..0000000000 --- a/client/src/redux/night-mode-saga.js +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable require-yield */ - -import { takeEvery } from 'redux-saga/effects'; -import store from 'store'; - -const themeKey = 'fcc-theme'; -const defaultTheme = 'default'; - -export function setTheme(currentTheme = defaultTheme, theme) { - if (currentTheme !== theme) { - store.set(themeKey, theme); - } -} - -function* updateLocalThemeSaga({ payload: { user, theme } }) { - const currentTheme = store.get(themeKey) || defaultTheme; - if (user) { - const { theme = defaultTheme } = user; - return setTheme(currentTheme, theme); - } - if (theme) { - return setTheme(currentTheme, theme); - } - return setTheme(currentTheme); -} - -export function createNightModeSaga(types) { - return [ - takeEvery(types.fetchUserComplete, updateLocalThemeSaga), - takeEvery(types.updateUserFlagComplete, updateLocalThemeSaga) - ]; -}