Skip to content

Commit

Permalink
Merge pull request #2562 from stakwork/bugfix/sequence
Browse files Browse the repository at this point in the history
fix: update edges handler
  • Loading branch information
Rassl authored Dec 19, 2024
2 parents a77ae10 + 471d4eb commit 1dfc7f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
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

0 comments on commit 1dfc7f0

Please sign in to comment.