Skip to content

Commit

Permalink
refactor(selection): only set new one if selection updated
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Aug 1, 2019
1 parent 22938ba commit 6b81436
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
17 changes: 13 additions & 4 deletions dist/ReactGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -30003,6 +30003,17 @@
selectedNodesBbox: selectedNodesBbox
});
}

case SET_SELECTED_ELEMENTS:
{
var _selectedElementsUpdated = !lodash_isequal(action.payload.selectedElements, state.selectedElements);

var selectedElements = _selectedElementsUpdated ? action.payload.selectedElements : state.selectedElements;
return _objectSpread2({}, state, {
selectedElements: selectedElements,
odesSelectionActive: false
});
}
// unused

case REMOVE_NODES:
Expand Down Expand Up @@ -30037,7 +30048,6 @@
case INIT_D3:
case UPDATE_SIZE:
case SET_SELECTION:
case SET_SELECTED_ELEMENTS:
case SET_CONNECTION_POS:
return _objectSpread2({}, state, {}, action.payload);

Expand Down Expand Up @@ -30152,8 +30162,7 @@
return {
type: SET_SELECTED_ELEMENTS,
payload: {
selectedElements: elementsArray,
nodesSelectionActive: false
selectedElements: elementsArray
}
};
};
Expand Down Expand Up @@ -33386,7 +33395,7 @@
})))));
});
WrappedComp.displayName = 'Wrapped Node';
WrappedComp.whyDidYouRender = false;
WrappedComp.whyDidYouRender = true;
return WrappedComp;
});

Expand Down
19 changes: 14 additions & 5 deletions example/build/example.e31bb0bc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37879,6 +37879,17 @@ var reducer = function reducer(state, action) {
selectedNodesBbox: selectedNodesBbox
});
}

case SET_SELECTED_ELEMENTS:
{
var _selectedElementsUpdated = !(0, _lodash.default)(action.payload.selectedElements, state.selectedElements);

var selectedElements = _selectedElementsUpdated ? action.payload.selectedElements : state.selectedElements;
return _objectSpread({}, state, {
selectedElements: selectedElements,
odesSelectionActive: false
});
}
// unused

case REMOVE_NODES:
Expand Down Expand Up @@ -37913,7 +37924,6 @@ var reducer = function reducer(state, action) {
case INIT_D3:
case UPDATE_SIZE:
case SET_SELECTION:
case SET_SELECTED_ELEMENTS:
case SET_CONNECTION_POS:
return _objectSpread({}, state, {}, action.payload);

Expand Down Expand Up @@ -38075,8 +38085,7 @@ var setSelectedElements = function setSelectedElements(elements) {
return {
type: _index.SET_SELECTED_ELEMENTS,
payload: {
selectedElements: elementsArray,
nodesSelectionActive: false
selectedElements: elementsArray
}
};
};
Expand Down Expand Up @@ -41778,7 +41787,7 @@ var _default = function _default(NodeComponent) {
})))));
});
WrappedComp.displayName = 'Wrapped Node';
WrappedComp.whyDidYouRender = false;
WrappedComp.whyDidYouRender = true;
return WrappedComp;
};

Expand Down Expand Up @@ -42650,7 +42659,7 @@ var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = "" || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + '://' + hostname + ':' + "53734" + '/');
var ws = new WebSocket(protocol + '://' + hostname + ':' + "57289" + '/');

ws.onmessage = function (event) {
checkedAssets = {};
Expand Down
2 changes: 1 addition & 1 deletion example/build/example.e31bb0bc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/NodeRenderer/NodeTypes/wrapNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default NodeComponent => {
});

WrappedComp.displayName = 'Wrapped Node';
WrappedComp.whyDidYouRender = false;
WrappedComp.whyDidYouRender = true;

return WrappedComp;
};
3 changes: 1 addition & 2 deletions src/state/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export const setSelectedElements = (elements) => {
return {
type: SET_SELECTED_ELEMENTS,
payload: {
selectedElements: elementsArray,
nodesSelectionActive: false
selectedElements: elementsArray
}
};
};
Expand Down
7 changes: 6 additions & 1 deletion src/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down

0 comments on commit 6b81436

Please sign in to comment.