Skip to content

Commit

Permalink
fix: update edges handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Rassl committed Dec 19, 2024
1 parent a77ae10 commit 3675d07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
35 changes: 14 additions & 21 deletions src/components/App/SideBar/SelectedNodeView/Default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
target_node?: Node
properties?: {
Expand All @@ -41,7 +36,7 @@ export const Default = () => {
const audioRef = useRef<HTMLAudioElement | null>(null)
const { currentPlayingAudio, setCurrentPlayingAudio } = useAppStore((s) => s)
const [isPlaying, setIsPlaying] = useState(false)
const [sequencedNodes, setSequencedNodes] = useState<SequencedNode[]>([])
const [sequencedNodes, setSequencedNodes] = useState<Node[]>([])
const [boostAmount, setBoostAmount] = useState<number>(selectedNode?.properties?.boost || 0)

const getIndexByType = useSchemaStore((s) => s.getIndexByType)
Expand All @@ -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)

Check failure on line 71 in src/components/App/SideBar/SelectedNodeView/Default/index.tsx

View workflow job for this annotation

GitHub Actions / craco-build-run

Argument of type '(Node | undefined)[]' is not assignable to parameter of type 'SetStateAction<Node[]>'.

Check failure on line 71 in src/components/App/SideBar/SelectedNodeView/Default/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Argument of type '(Node | undefined)[]' is not assignable to parameter of type 'SetStateAction<Node[]>'.
}
Expand Down Expand Up @@ -185,10 +179,10 @@ export const Default = () => {

{sequencedNodes.length > 0 && (
<StyledSequenceWrapper>
{sequencedNodes.map((item, idx) => (
<React.Fragment key={`${item.node.ref_id}-${item.sequence}`}>
<Text>{getNodeContent(item.node)}</Text>
{idx < sequencedNodes.length - 1 && <StyledLineBreak />}
{sequencedNodes.map((item, index) => (
<React.Fragment key={`${item.ref_id}`}>
<Text>{getNodeContent(item)}</Text>
{index < sequencedNodes.length - 1 && <StyledLineBreak />}
</React.Fragment>
))}
</StyledSequenceWrapper>
Expand Down Expand Up @@ -373,6 +367,5 @@ const StyledSequenceWrapper = styled(Flex)`
const StyledLineBreak = styled.div`
width: 100%;
height: 1px;
background-color: ${colors.GRAY3};
margin: 8px 0;
`
2 changes: 0 additions & 2 deletions src/components/Universe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -148,7 +147,6 @@ const _Universe = () => {
</Suspense>
{universeQuestionIsOpen && <UniverseQuestion />}
{isLoading && <Preloader fullSize={false} />}
<CursorTooltip />
<Overlay />
</Wrapper>
)
Expand Down

0 comments on commit 3675d07

Please sign in to comment.