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:
parent
b3c9aa121d
commit
bb3791987d
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user