Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Handle new geoblock case or geoblock with no value
Browse files Browse the repository at this point in the history
  • Loading branch information
hoanphungt committed Oct 19, 2021
1 parent b2f2d9a commit 945dfb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/createGraphLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createGraphLayout = (
const nodeHeight = 36;

const source: GeoBlockSource = JSON.parse(jsonString);
const allBlockNames = Object.keys(source.graph);
const allBlockNames = source && source.graph ? Object.keys(source.graph) : [];

elements.forEach(el => {
dagreGraph.setNode(el.id, {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/geoblockUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ export const convertGeoblockSourceToFlowElements = (
setElements: React.Dispatch<React.SetStateAction<Elements<any>>>
) => {
const source: GeoBlockSource = JSON.parse(jsonString);

// Return empty array if it is a new geoblock or the geoblock has no value yet
if (!source || !source.graph) return [];

const rasterElements = getRasterElements(source.graph, setElements);
const blockElements = getBlockElements(source, setElements);
const numberElements = getNumberElements(blockElements, setElements);
Expand Down

0 comments on commit 945dfb6

Please sign in to comment.