diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-09-12 19:38:51 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-09-12 19:38:51 +0200 |
commit | a21b4afd4f54a53e5d563c3d02195e05f48a4700 (patch) | |
tree | 80f88f77b326cac182ef38ae14b6bc3a2e8f12c8 /pages | |
parent | 2f6545337d832c766feaae1854b936bb3d1d9557 (diff) |
fix: #81 Ui now loads on empty db
Diffstat (limited to 'pages')
-rw-r--r-- | pages/index.tsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 421ead4..d4235d7 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -95,7 +95,9 @@ export function GraphPage() { const updateGraphData = (orgRoamGraphData: OrgRoamGraphReponse) => { const oldNodeById = nodeByIdRef.current tagsRef.current = orgRoamGraphData.tags ?? [] - const nodesByFile = orgRoamGraphData.nodes.reduce<NodesByFile>((acc, node) => { + const importNodes = orgRoamGraphData.nodes ?? [] + const importLinks = orgRoamGraphData.links ?? [] + const nodesByFile = importNodes.reduce<NodesByFile>((acc, node) => { return { ...acc, [node.file]: [...(acc[node.file] ?? []), node], @@ -161,8 +163,8 @@ export function GraphPage() { }) }) - nodeByIdRef.current = Object.fromEntries(orgRoamGraphData.nodes.map((node) => [node.id, node])) - const dirtyLinks = [...orgRoamGraphData.links, ...headingLinks, ...fileLinks] + nodeByIdRef.current = Object.fromEntries(importNodes.map((node) => [node.id, node])) + const dirtyLinks = [...importLinks, ...headingLinks, ...fileLinks] const nonExistantNodes: OrgRoamNode[] = [] const links = dirtyLinks.map((link) => { const sourceId = link.source as string @@ -209,7 +211,7 @@ export function GraphPage() { } }, {}) - const nodes = [...orgRoamGraphData.nodes, ...nonExistantNodes] + const nodes = [...importNodes, ...nonExistantNodes] const orgRoamGraphDataProcessed = { nodes, links, |