summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-08-01 16:28:34 +0200
committerThomas F. K. Jorna <[email protected]>2021-08-01 16:28:34 +0200
commit11298a51b44b6bc17c34522deac5f5ac370340a0 (patch)
tree101af2bbd8e7e1270aecc6ae6534387f84daae98 /pages
parent361e20367c20e4bae6a02391a6852bb345fadc9a (diff)
fixed filtering for dirty links
Diffstat (limited to 'pages')
-rw-r--r--pages/index.tsx15
1 files changed, 8 insertions, 7 deletions
diff --git a/pages/index.tsx b/pages/index.tsx
index afb4bad..82c203c 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -107,7 +107,13 @@ export function GraphPage() {
nodeByIdRef.current = Object.fromEntries(orgRoamGraphData.nodes.map((node) => [node.id, node]))
- const links = [...orgRoamGraphData.links, ...fileLinks]
+ const dirtyLinks = [...orgRoamGraphData.links, ...fileLinks]
+ const links = dirtyLinks.filter((link) => {
+ const sourceId = link.source as string
+ const targetId = link.target as string
+ return nodeByIdRef.current[sourceId] && nodeByIdRef.current[targetId]
+ })
+
linksByNodeIdRef.current = links.reduce<LinksByNodeId>((acc, link) => {
return {
...acc,
@@ -410,12 +416,7 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
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') &&
- filteredNodeIds.includes(link.source as string) &&
- filteredNodeIds.includes(link.target)
- )
+ return link.type !== 'cite' && (filter.parents || link.type !== 'parent')
})
const scopedNodes = filteredNodes.filter((node) => {