From 565f99190c29c02ab1dcd5f72ded466ee96a3837 Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Sun, 1 Aug 2021 00:03:52 +0200
Subject: fixed missing links issue

---
 pages/index.tsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index ccdb07d..7b84222 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -407,9 +407,15 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
       return links.some((link) => !['parent', 'cite', 'ref'].includes(link.type))
     })
 
+    const filteredNodeIds = filteredNodes.map((node) => node.id as string)
     const filteredLinks = graphData.links.filter((linkArg) => {
       const link = linkArg as OrgRoamLink
-      return link.type !== 'cite' && (filter.parents || link.type !== 'parent')
+      return (
+        link.type !== 'cite' &&
+        (filter.parents || link.type !== 'parent') &&
+        filteredNodeIds.includes(link.source as string) &&
+        filteredNodeIds.includes(link.target)
+      )
     })
 
     const scopedNodes = filteredNodes.filter((node) => {
@@ -429,7 +435,6 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
       // but if we supply the original data on each render, the graph will re-render sporadically
       const sourceId = typeof link.source === 'object' ? link.source.id! : (link.source as string)
       const targetId = typeof link.target === 'object' ? link.target.id! : (link.target as string)
-
       return (
         scopedNodeIds.includes(sourceId as string) && scopedNodeIds.includes(targetId as string)
       )
-- 
cgit v1.2.3

