MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / getHighlightedSibling

Function getHighlightedSibling

app/useColumnView/index.ts:580–613  ·  view source on GitHub ↗
(
  state: ColumnViewState,
  nodeTable: NodeTable,
  direction: -1 | 1
)

Source from the content-addressed store, hash-verified

578}
579
580function getHighlightedSibling(
581 state: ColumnViewState,
582 nodeTable: NodeTable,
583 direction: -1 | 1
584): string | undefined {
585 const { highlightedNodeId } = state;
586
587 if (!highlightedNodeId) {
588 return;
589 }
590
591 const highlightedNode = nodeTable[highlightedNodeId];
592
593 if (!highlightedNode || !highlightedNode.parentId) {
594 return;
595 }
596
597 const parentNode = nodeTable[highlightedNode.parentId];
598
599 if (!parentNode) {
600 return;
601 }
602
603 const highlightedIndex = parentNode.children.indexOf(highlightedNodeId);
604 const nextIndex = highlightedIndex + direction;
605
606 if (parentNode.children.length <= nextIndex || nextIndex < 0) {
607 return;
608 }
609
610 const nextNodeId = parentNode.children[nextIndex];
611
612 return nextNodeId;
613}

Callers 1

columnViewReducerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected