Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update edges handler #2562

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 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,18 +58,18 @@ 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) || []

setSequencedNodes(nodesWithSequence)
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))

const filteredNodes = nodesWithSequence.filter((i) => !!i)

setSequencedNodes(filteredNodes as Node[])
}
}
}
Expand Down Expand Up @@ -185,10 +180,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 +368,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
Loading