From bb3791987def4310ca22e6f07bf8544420aa4233 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Thu, 24 Nov 2016 20:30:06 +0100 Subject: [PATCH] simplify immutable js --- frontend/src/component/history/history-list-container.jsx | 6 +----- frontend/src/store/settings/index.js | 8 +------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/frontend/src/component/history/history-list-container.jsx b/frontend/src/component/history/history-list-container.jsx index b7215486af..df8a725a80 100644 --- a/frontend/src/component/history/history-list-container.jsx +++ b/frontend/src/component/history/history-list-container.jsx @@ -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, diff --git a/frontend/src/store/settings/index.js b/frontend/src/store/settings/index.js index d6f0aab1b6..12d883b154 100644 --- a/frontend/src/store/settings/index.js +++ b/frontend/src/store/settings/index.js @@ -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;