From 3675d071d6eee7348510bab16c8e96c77323d3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Thu, 19 Dec 2024 18:00:58 +0300 Subject: [PATCH 1/2] fix: update edges handler --- .../SelectedNodeView/Default/index.tsx | 35 ++++++++----------- src/components/Universe/index.tsx | 2 -- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/src/components/App/SideBar/SelectedNodeView/Default/index.tsx b/src/components/App/SideBar/SelectedNodeView/Default/index.tsx index c043388f5..d3587d77e 100644 --- a/src/components/App/SideBar/SelectedNodeView/Default/index.tsx +++ b/src/components/App/SideBar/SelectedNodeView/Default/index.tsx @@ -23,11 +23,6 @@ import { Link, Node } from '~/types' import { colors } from '~/utils/colors' import { BoostAmt } from '../../../Helper/BoostAmt' -interface SequencedNode { - node: Node - sequence: number -} - interface EdgeWithTargetNode extends Link { target_node?: Node properties?: { @@ -41,7 +36,7 @@ export const Default = () => { const audioRef = useRef(null) const { currentPlayingAudio, setCurrentPlayingAudio } = useAppStore((s) => s) const [isPlaying, setIsPlaying] = useState(false) - const [sequencedNodes, setSequencedNodes] = useState([]) + const [sequencedNodes, setSequencedNodes] = useState([]) const [boostAmount, setBoostAmount] = useState(selectedNode?.properties?.boost || 0) const getIndexByType = useSchemaStore((s) => s.getIndexByType) @@ -63,16 +58,15 @@ export const Default = () => { }) if (response) { - const nodesWithSequence = - response.edges - ?.filter( - (edge: EdgeWithTargetNode) => edge.properties?.sequence !== undefined && edge.target_node !== undefined, - ) - .map((edge: EdgeWithTargetNode) => ({ - node: edge.target_node as Node, - sequence: edge.properties?.sequence as number, - })) - .sort((a, b) => a.sequence - b.sequence) || [] + const nodesWithSequence = response.edges + ?.filter((edge: EdgeWithTargetNode) => edge.properties?.sequence !== undefined) + .map((edge: EdgeWithTargetNode) => ({ + node: edge.target, + sequence: edge.properties?.sequence as number, + })) + .sort((a, b) => a.sequence - b.sequence) + .map((i) => response.nodes.find((n) => n.ref_id === i.node)) + .filter((i) => !!i) setSequencedNodes(nodesWithSequence) } @@ -185,10 +179,10 @@ export const Default = () => { {sequencedNodes.length > 0 && ( - {sequencedNodes.map((item, idx) => ( - - {getNodeContent(item.node)} - {idx < sequencedNodes.length - 1 && } + {sequencedNodes.map((item, index) => ( + + {getNodeContent(item)} + {index < sequencedNodes.length - 1 && } ))} @@ -373,6 +367,5 @@ const StyledSequenceWrapper = styled(Flex)` const StyledLineBreak = styled.div` width: 100%; height: 1px; - background-color: ${colors.GRAY3}; margin: 8px 0; ` diff --git a/src/components/Universe/index.tsx b/src/components/Universe/index.tsx index d2a16d578..3a5ce713e 100644 --- a/src/components/Universe/index.tsx +++ b/src/components/Universe/index.tsx @@ -21,7 +21,6 @@ import { Flex } from '../common/Flex' import { outlineEffectColor } from './constants' import { Controls } from './Controls' import { initialCameraPosition } from './Controls/CameraAnimations/constants' -import { CursorTooltip } from './CursorTooltip' import { Graph } from './Graph' import { Lights } from './Lights' import { Overlay } from './Overlay' @@ -148,7 +147,6 @@ const _Universe = () => { {universeQuestionIsOpen && } {isLoading && } - ) From 471d4eb01cfbcd497acedd90a92b4978f4eb6853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B0=D1=81=D1=83=D0=BB?= Date: Thu, 19 Dec 2024 18:06:56 +0300 Subject: [PATCH 2/2] fix: fix build error --- .../App/SideBar/SelectedNodeView/Default/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/App/SideBar/SelectedNodeView/Default/index.tsx b/src/components/App/SideBar/SelectedNodeView/Default/index.tsx index d3587d77e..efdb4c80a 100644 --- a/src/components/App/SideBar/SelectedNodeView/Default/index.tsx +++ b/src/components/App/SideBar/SelectedNodeView/Default/index.tsx @@ -66,9 +66,10 @@ export const Default = () => { })) .sort((a, b) => a.sequence - b.sequence) .map((i) => response.nodes.find((n) => n.ref_id === i.node)) - .filter((i) => !!i) - setSequencedNodes(nodesWithSequence) + const filteredNodes = nodesWithSequence.filter((i) => !!i) + + setSequencedNodes(filteredNodes as Node[]) } } }