2016-06-22 19:58:23 +00:00
|
|
|
import * as ActionTypes from '../../../constants';
|
2016-06-17 17:37:29 +00:00
|
|
|
|
|
|
|
const initialState = {
|
2016-07-06 15:27:39 +00:00
|
|
|
fontSize: 18,
|
2016-08-11 18:09:59 +00:00
|
|
|
autosave: true,
|
2019-03-26 19:37:44 +00:00
|
|
|
linewrap: true,
|
2016-08-12 19:50:33 +00:00
|
|
|
lintWarning: false,
|
2017-05-31 19:23:30 +00:00
|
|
|
textOutput: false,
|
|
|
|
gridOutput: false,
|
|
|
|
soundOutput: false,
|
2016-09-28 18:12:01 +00:00
|
|
|
theme: 'light',
|
2016-10-04 19:35:23 +00:00
|
|
|
autorefresh: false
|
2016-06-23 22:29:55 +00:00
|
|
|
};
|
2016-06-17 17:37:29 +00:00
|
|
|
|
|
|
|
const preferences = (state = initialState, action) => {
|
2016-06-23 22:29:55 +00:00
|
|
|
switch (action.type) {
|
2016-08-04 03:45:49 +00:00
|
|
|
case ActionTypes.SET_FONT_SIZE:
|
|
|
|
return Object.assign({}, state, { fontSize: action.value });
|
2016-08-09 20:15:28 +00:00
|
|
|
case ActionTypes.SET_AUTOSAVE:
|
|
|
|
return Object.assign({}, state, { autosave: action.value });
|
2019-03-26 19:37:44 +00:00
|
|
|
case ActionTypes.SET_LINEWRAP:
|
|
|
|
return Object.assign({}, state, { linewrap: action.value });
|
2016-08-11 18:09:59 +00:00
|
|
|
case ActionTypes.SET_LINT_WARNING:
|
|
|
|
return Object.assign({}, state, { lintWarning: action.value });
|
2016-08-12 19:50:33 +00:00
|
|
|
case ActionTypes.SET_TEXT_OUTPUT:
|
|
|
|
return Object.assign({}, state, { textOutput: action.value });
|
2017-05-31 19:23:30 +00:00
|
|
|
case ActionTypes.SET_GRID_OUTPUT:
|
|
|
|
return Object.assign({}, state, { gridOutput: action.value });
|
|
|
|
case ActionTypes.SET_SOUND_OUTPUT:
|
|
|
|
return Object.assign({}, state, { soundOutput: action.value });
|
2016-08-09 21:50:45 +00:00
|
|
|
case ActionTypes.SET_PREFERENCES:
|
|
|
|
return action.preferences;
|
2016-09-13 18:15:46 +00:00
|
|
|
case ActionTypes.SET_THEME:
|
|
|
|
return Object.assign({}, state, { theme: action.value });
|
2016-09-28 18:12:01 +00:00
|
|
|
case ActionTypes.SET_AUTOREFRESH:
|
|
|
|
return Object.assign({}, state, { autorefresh: action.value });
|
2016-06-23 22:29:55 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
};
|
2016-06-17 17:37:29 +00:00
|
|
|
|
2016-06-23 22:29:55 +00:00
|
|
|
export default preferences;
|