MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / toggleThemeSaga

Function toggleThemeSaga

client/src/redux/theme-saga.js:7–14  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { userThemeSelector } from './selectors';
6
7function* toggleThemeSaga() {
8 const data = { type: 'success', message: 'flash.updated-themes' };
9 const currentTheme = localStorage.getItem('theme');
10 const invertedTheme = currentTheme === 'dark' ? 'light' : 'dark';
11 localStorage.setItem('theme', invertedTheme);
12 yield put(setTheme(invertedTheme));
13 yield put(createFlashMessage({ ...data }));
14}
15
16export function* initializeThemeSaga() {
17 // Wait for the fetch userComplete action

Callers

nothing calls this directly

Calls 3

createFlashMessageFunction · 0.90
putFunction · 0.85
setThemeFunction · 0.85

Tested by

no test coverage detected