1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

simplify immutable js

This commit is contained in:
ivaosthu 2016-11-24 20:30:06 +01:00
parent b3c9aa121d
commit bb3791987d
2 changed files with 2 additions and 12 deletions

View File

@ -3,11 +3,7 @@ import HistoryListComponent from './history-list-component';
import { updateSettingForGroup } from '../../store/settings/actions';
const mapStateToProps = (state) => {
let settings = {};
const historySettings = state.settings.get('history');
if (historySettings) {
settings = historySettings.toJS();
}
const settings = state.settings.toJS().history || {};
return {
settings,

View File

@ -15,13 +15,7 @@ function getInitState () {
}
function updateSetting (state, action) {
let newState;
if (state.get(action.group)) {
newState = state.updateIn([action.group, action.field], () => action.value);
} else {
newState = state.set(action.group, new $Map())
.updateIn([action.group, action.field], () => action.value);
}
const newState = state.updateIn([action.group, action.field], () => action.value);
localStorage.setItem(SETTINGS, JSON.stringify(newState.toJSON()));
return newState;