refactor(selection): only set new one if selection updated

This commit is contained in:
moklick
2019-08-01 13:28:22 +02:00
parent 22938baa93
commit 6b81436316
7 changed files with 37 additions and 15 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ export default NodeComponent => {
});
WrappedComp.displayName = 'Wrapped Node';
WrappedComp.whyDidYouRender = false;
WrappedComp.whyDidYouRender = true;
return WrappedComp;
};
+1 -2
View File
@@ -81,8 +81,7 @@ export const setSelectedElements = (elements) => {
return {
type: SET_SELECTED_ELEMENTS,
payload: {
selectedElements: elementsArray,
nodesSelectionActive: false
selectedElements: elementsArray
}
};
};
+6 -1
View File
@@ -120,6 +120,12 @@ export const reducer = (state, action) => {
return { ...state, ...action.payload, selectedNodesBbox };
}
case SET_SELECTED_ELEMENTS: {
const selectedElementsUpdated = !isEqual(action.payload.selectedElements, state.selectedElements);
const selectedElements = selectedElementsUpdated ? action.payload.selectedElements : state.selectedElements;
return { ...state, selectedElements, odesSelectionActive: false };
}
// unused
case REMOVE_NODES: {
const { ids } = action.payload;
@@ -141,7 +147,6 @@ export const reducer = (state, action) => {
case INIT_D3:
case UPDATE_SIZE:
case SET_SELECTION:
case SET_SELECTED_ELEMENTS:
case SET_CONNECTION_POS:
return { ...state, ...action.payload };
default: