1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-12 13:48:35 +02: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'; import { updateSettingForGroup } from '../../store/settings/actions';
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
let settings = {}; const settings = state.settings.toJS().history || {};
const historySettings = state.settings.get('history');
if (historySettings) {
settings = historySettings.toJS();
}
return { return {
settings, settings,

View File

@ -15,13 +15,7 @@ function getInitState () {
} }
function updateSetting (state, action) { function updateSetting (state, action) {
let newState; const newState = state.updateIn([action.group, action.field], () => action.value);
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);
}
localStorage.setItem(SETTINGS, JSON.stringify(newState.toJSON())); localStorage.setItem(SETTINGS, JSON.stringify(newState.toJSON()));
return newState; return newState;