diff options
author | Kirill Rogovoy <[email protected]> | 2021-07-29 17:18:52 +0300 |
---|---|---|
committer | Kirill Rogovoy <[email protected]> | 2021-07-29 17:18:52 +0300 |
commit | 4e3d884c402b7dc7d12f0cae88a9a312b10f166f (patch) | |
tree | 2c451f95a88d53ca37edc8780365ea65a90d0560 /pages/index.tsx | |
parent | 70b5c59233dbdae0b780746c25f7cef156f77fc9 (diff) |
Minor refactoring
Diffstat (limited to 'pages/index.tsx')
-rw-r--r-- | pages/index.tsx | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 51b21fc..e0e8b6e 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -246,25 +246,19 @@ export const Graph = function (props: GraphProps) { const filteredNodes = useMemo(() => { return graphData.nodes.filter((node) => { const links = linksByNodeId[node.id as string] ?? [] - let showNode = true - if (filter.orphans) { - if (filter.parents) { - showNode = links.length !== 0 - } else { - if (links.length === 0) { - showNode = false - } else { - if ( - links.length - - links.filter((link) => link.type === 'parent' || link.type === 'cite').length === - 0 - ) { - showNode = false - } - } - } + if (!filter.orphans) { + return true } - return showNode + + if (filter.parents) { + return links.length !== 0 + } + + if (links.length === 0) { + return false + } + + return !links.some(link => !['parent', 'cite'].includes(link.type)) }) }, [filter, graphData.nodes, linksByNodeId]) @@ -491,7 +485,7 @@ export const Graph = function (props: GraphProps) { if (!visuals.linkColorScheme) { return highlightColors[getLinkNodeColor(sourceId, targetId)][visuals.linkHighlight](opacity) } - + return highlightColors[visuals.linkColorScheme][visuals.linkHighlight](opacity) } |