Skip to content

Commit

Permalink
fix(sidebar): sequenced nodes view
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Dec 19, 2024
1 parent 209e849 commit 9c6180a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/App/SideBar/SelectedNodeView/Default/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { fetchNodeEdges } from '~/network/fetchGraphData'
import { useAppStore } from '~/stores/useAppStore'
import { useSelectedNode } from '~/stores/useGraphStore'
import { usePlayerStore } from '~/stores/usePlayerStore'
import { useSchemaStore } from '~/stores/useSchemaStore'
import { Link, Node } from '~/types'
import { colors } from '~/utils/colors'
import { BoostAmt } from '../../../Helper/BoostAmt'
Expand All @@ -43,6 +44,7 @@ export const Default = () => {
const [sequencedNodes, setSequencedNodes] = useState<SequencedNode[]>([])
const [boostAmount, setBoostAmount] = useState<number>(selectedNode?.properties?.boost || 0)

const getIndexByType = useSchemaStore((s) => s.getIndexByType)
const { playingNode } = usePlayerStore((s) => s)

useEffect(() => {
Expand Down Expand Up @@ -132,6 +134,12 @@ export const Default = () => {
const sourceLink = selectedNode.properties?.source_link
const pubkey = selectedNode.properties?.pubkey

const getNodeContent = (node: Node) => {
const keyProp = getIndexByType(node.node_type)

return keyProp ? node.properties?.[keyProp] : node.label
}

return (
<StyledContainer>
{hasImage && (
Expand Down Expand Up @@ -179,7 +187,7 @@ export const Default = () => {
<StyledSequenceWrapper>
{sequencedNodes.map((item, idx) => (
<React.Fragment key={`${item.node.ref_id}-${item.sequence}`}>
<Text>{item.node.properties?.index || item.node.properties?.text}</Text>
<Text>{getNodeContent(item.node)}</Text>
{idx < sequencedNodes.length - 1 && <StyledLineBreak />}
</React.Fragment>
))}
Expand Down

0 comments on commit 9c6180a

Please sign in to comment.