Skip to content

Local storage #2158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const SET_LINE_NUMBERS = 'SET_LINE_NUMBERS';
export const AUTH_USER = 'AUTH_USER';
export const UNAUTH_USER = 'UNAUTH_USER';
export const AUTH_ERROR = 'AUTH_ERROR';
export const THEME_KEY = 'THEME_KEY';

export const SETTINGS_UPDATED = 'SETTINGS_UPDATED';

Expand Down
4 changes: 3 additions & 1 deletion client/modules/IDE/reducers/preferences.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { THEME_KEY } from '../../../constants';
import * as ActionTypes from '../../../constants';

const initialState = {
Expand All @@ -8,7 +9,7 @@ const initialState = {
lintWarning: false,
textOutput: false,
gridOutput: false,
theme: 'light',
theme: localStorage.getItem(THEME_KEY) || 'light',
autorefresh: false,
language: 'en-US',
autocloseBracketsQuotes: true
Expand All @@ -31,6 +32,7 @@ const preferences = (state = initialState, action) => {
case ActionTypes.SET_PREFERENCES:
return action.preferences;
case ActionTypes.SET_THEME:
localStorage.setItem(THEME_KEY, action.value);
return Object.assign({}, state, { theme: action.value });
case ActionTypes.SET_AUTOREFRESH:
return Object.assign({}, state, { autorefresh: action.value });
Expand Down