Skip to content

Commit

Permalink
Merge pull request #427 from kreneskyp/first_node_fix
Browse files Browse the repository at this point in the history
Initial nodes were added to graph with null chain_id.
  • Loading branch information
kreneskyp authored Feb 3, 2024
2 parents 3afc955 + fb1db40 commit b46bfaf
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions frontend/chains/ChainGraphEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,23 @@ const ChainGraphEditor = ({ graph }) => {
if (chain?.id === undefined) {
loadChain(`/api/chains/${response.data.chain_id}`, {
onSuccess: (response) => {
tabState.setActive((prev) => ({
...prev,
chain_id: response.data.id,
chain: response.data,
}));
tabState.setActive((prev) => {
// update any initial nodes that are missing chain_id
const nodes = { ...prev.nodes };
for (const id in nodes) {
const node = nodes[id];
if (node.chain_id === null) {
nodes[id] = { ...node, chain_id: response.data.id };
}
}

return {
...prev,
chain_id: response.data.id,
chain: response.data,
nodes,
};
});
toast({ ...NOTIFY_SAVED, description: "Saved Chain" });
},
});
Expand Down

0 comments on commit b46bfaf

Please sign in to comment.