Skip to content

Commit

Permalink
Merge pull request #47 from igloo-4002/fix/clear-canvas-on-upload
Browse files Browse the repository at this point in the history
fix: clear canvas on upload
  • Loading branch information
MutazAshhab authored Sep 4, 2023
2 parents 691bf4f + 3b67e87 commit 5c01edc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/ProjectUploadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export function ProjectUploadButton() {
const parsedJson = JSON.parse(e.target?.result as string);
const network = getNetworkFromUploadedFile(parsedJson);

// Clear the current canvas
const nodeIds = Object.keys(networkStore.nodes);
nodeIds.forEach(nodeId => {
networkStore.deleteNode(nodeId);
});

// Update the state with the network
Object.values(network.networkData.nodes).forEach(node => {
networkStore.addNode(node);
Expand Down

0 comments on commit 5c01edc

Please sign in to comment.