Skip to content

Commit

Permalink
refactor: updated added portal logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Feb 27, 2021
1 parent cd3fcb7 commit 708f8f3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/state/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ const addPortal = (
registerHost(draft, hostName);
}

draft[hostName].push({
name: portalName,
node,
});
/**
* updated portal, if it was already added.
*/
const index = draft[hostName].findIndex(item => item.name === portalName);
if (index !== -1) {
draft[hostName][index].node = node;
} else {
draft[hostName].push({
name: portalName,
node,
});
}
};

const updatePortal = (
Expand Down

0 comments on commit 708f8f3

Please sign in to comment.