summaryrefslogtreecommitdiff
path: root/pages/index.tsx
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-10-15 13:37:53 +0200
committerThomas F. K. Jorna <[email protected]>2021-10-15 13:37:53 +0200
commitcab6dae73e524e3917500583b169fd81bf3f9487 (patch)
tree41004376dd5e4546e32f0182ae7c30ed13d323b0 /pages/index.tsx
parent556a3caa4371a5cbc661b29622f0effad4f52671 (diff)
feat(neighbs): add ability to show nth neighbor
Diffstat (limited to 'pages/index.tsx')
-rw-r--r--pages/index.tsx18
1 files changed, 16 insertions, 2 deletions
diff --git a/pages/index.tsx b/pages/index.tsx
index a998c82..9eb1874 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -40,6 +40,7 @@ import {
colorList,
initialBehavior,
initialFilter,
+ initialLocal,
initialMouse,
initialPhysics,
initialVisuals,
@@ -105,6 +106,7 @@ export function GraphPage() {
const [emacsNodeId, setEmacsNodeId] = useState<string | null>(null)
const [behavior, setBehavior] = usePersistantState('behavior', initialBehavior)
const [mouse, setMouse] = usePersistantState('mouse', initialMouse)
+ const [local, setLocal] = usePersistantState('local', initialLocal)
const [
previewNodeState,
{
@@ -539,6 +541,8 @@ export function GraphPage() {
setBehavior,
tagColors,
setTagColors,
+ local,
+ setLocal,
}}
tags={tagsRef.current}
/>
@@ -573,6 +577,7 @@ export function GraphPage() {
setMainWindowWidth,
setContextMenuTarget,
graphRef,
+ local,
}}
/>
)}
@@ -680,6 +685,7 @@ export interface GraphProps {
visuals: typeof initialVisuals
behavior: typeof initialBehavior
mouse: typeof initialMouse
+ local: typeof initialLocal
scope: Scope
setScope: any
webSocket: any
@@ -712,6 +718,7 @@ export const Graph = function (props: GraphProps) {
behavior,
mouse,
scope,
+ local,
setScope,
webSocket,
tagColors,
@@ -895,7 +902,7 @@ export const Graph = function (props: GraphProps) {
}
const oldScopedNodes = scope.nodeIds.length > 1 ? scopedGraphData.nodes : []
const oldScopedNodeIds = oldScopedNodes.map((node) => node.id as string)
- const neighbs = findNthNeighbors(scope.nodeIds, 1)
+ const neighbs = findNthNeighbors(scope.nodeIds, local.neighbors)
const newScopedNodes = filteredGraphData.nodes
.filter((node) => {
if (oldScopedNodes.length) {
@@ -943,7 +950,14 @@ export const Graph = function (props: GraphProps) {
const scopedLinks = [...oldScopedLinks, ...newScopedLinks]
setScopedGraphData({ nodes: scopedNodes, links: scopedLinks })
- }, [filter, scope, JSON.stringify(graphData), filteredGraphData.links, filteredGraphData.nodes])
+ }, [
+ local.neighbors,
+ filter,
+ scope,
+ JSON.stringify(graphData),
+ filteredGraphData.links,
+ filteredGraphData.nodes,
+ ])
useEffect(() => {
;(async () => {