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