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