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.
This commit is contained in:
committed by
GitHub
parent
93ad0ae036
commit
e209582daf
@ -13,7 +13,6 @@ import { createFetchUserSaga } from './fetch-user-saga';
|
|||||||
import { createGaSaga } from './ga-saga';
|
import { createGaSaga } from './ga-saga';
|
||||||
|
|
||||||
import hardGoToEpic from './hard-go-to-epic';
|
import hardGoToEpic from './hard-go-to-epic';
|
||||||
import { createNightModeSaga } from './night-mode-saga';
|
|
||||||
import { createReportUserSaga } from './report-user-saga';
|
import { createReportUserSaga } from './report-user-saga';
|
||||||
|
|
||||||
import { actionTypes as settingsTypes } from './settings/action-types';
|
import { actionTypes as settingsTypes } from './settings/action-types';
|
||||||
@ -75,8 +74,7 @@ export const sagas = [
|
|||||||
...createGaSaga(actionTypes),
|
...createGaSaga(actionTypes),
|
||||||
...createFetchUserSaga(actionTypes),
|
...createFetchUserSaga(actionTypes),
|
||||||
...createShowCertSaga(actionTypes),
|
...createShowCertSaga(actionTypes),
|
||||||
...createReportUserSaga(actionTypes),
|
...createReportUserSaga(actionTypes)
|
||||||
...createNightModeSaga({ ...actionTypes, ...settingsTypes })
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const appMount = createAction(actionTypes.appMount);
|
export const appMount = createAction(actionTypes.appMount);
|
||||||
|
@ -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)
|
|
||||||
];
|
|
||||||
}
|
|
Reference in New Issue
Block a user