Skip to content

Commit

Permalink
Merge pull request #743 from VirtualFlyBrain/feature/737
Browse files Browse the repository at this point in the history
Fixes out of bounds array bug in redux store's add_instance method
  • Loading branch information
ddelpiano authored Nov 5, 2020
2 parents 047f1be + 9b470a7 commit f533850
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions reducers/generals.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,22 +257,24 @@ function generalReducer (state, action) {
case INSTANCE_ADDED:
var newMap = { ...state.idsMap };
var newInstance = action.data.split(".");
var component = returnComponent(newInstance[1]);
if (newMap[newInstance[0]] !== undefined
&& component !== null
&& newMap[newInstance[0]].components[component] === undefined
&& Instances[newInstance[0]][newInstance[1]] !== undefined) {
var newComponents = { ...newMap[newInstance[0]].components };
newMap[newInstance[0]].components = newComponents;
if (state.ui.layout[component]) {
newMap[newInstance[0]].components[component] = {
loaded: false,
loadable: true
}
} else {
newMap[newInstance[0]].components[component] = {
loaded: true,
loadable: false
if ( newInstance[1] !== undefined ){
var component = returnComponent(newInstance[1]);
if (newMap[newInstance[0]] !== undefined
&& component !== null
&& newMap[newInstance[0]].components[component] === undefined
&& Instances[newInstance[0]][newInstance[1]] !== undefined) {
var newComponents = { ...newMap[newInstance[0]].components };
newMap[newInstance[0]].components = newComponents;
if (state.ui.layout[component]) {
newMap[newInstance[0]].components[component] = {
loaded: false,
loadable: true
}
} else {
newMap[newInstance[0]].components[component] = {
loaded: true,
loadable: false
}
}
}
}
Expand Down

0 comments on commit f533850

Please sign in to comment.