From 2c7e57152078bafc01edd888b169eee3f3b71722 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 16 Jan 2018 09:49:36 -0800 Subject: [PATCH] feat(Panes): Do not update state if panes are the same This reduces the number of updates required when transitioning between challenges while preserving the state of the panes when going from two similar challengees. --- common/app/Panes/redux/index.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/common/app/Panes/redux/index.js b/common/app/Panes/redux/index.js index 511a159830..02a7f028c6 100644 --- a/common/app/Panes/redux/index.js +++ b/common/app/Panes/redux/index.js @@ -166,24 +166,22 @@ export default function createPanesAspects({ createPanesMap }) { const panesMap = action.meta.panesMap; const panes = _.map(panesMap, (name, type) => ({ name, type })); const numOfPanes = Object.keys(panes).length; - const panesByName = _.isEqual(state.panes, panes) && state.panesByName; + if (_.isEqual(state.panes, panes)) { + return state; + } return { ...state, panesMap, panes, - panesByName: panesByName - ? panesByName - : panes.reduce((panes, { name }, index) => { - const dividerLeft = utils.getDividerLeft(numOfPanes, index); - panes[name] = { - name, - dividerLeft, - isHidden: false - }; - return panes; - }, - {} - ) + panesByName: panes.reduce((panes, { name }, index) => { + const dividerLeft = utils.getDividerLeft(numOfPanes, index); + panes[name] = { + name, + dividerLeft, + isHidden: false + }; + return panes; + }, {}) }; } if (action.meta && action.meta.isPaneAction) {