Skip to content

Commit

Permalink
♻️ Replace hidden update logic with a shared function.
Browse files Browse the repository at this point in the history
  • Loading branch information
junkisai committed Feb 14, 2025
1 parent b746784 commit 5ce3616
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/lucky-flowers-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@liam-hq/erd-core": patch
"@liam-hq/cli": patch
---

♻️ Replace hidden update logic with a shared function.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import type { Node } from '@xyflow/react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useERDContentContext } from './ERDContentContext'
import { computeAutoLayout } from './computeAutoLayout'
import { hasNonRelatedChildNodes } from './hasNonRelatedChildNodes'
import { highlightNodesAndEdges } from './highlightNodesAndEdges'
import { updateNodesHiddenState } from './updateNodesHiddenState'

export const useInitialAutoLayout = (
nodes: Node[],
Expand Down Expand Up @@ -49,10 +51,12 @@ export const useInitialAutoLayout = (

if (tableNodesInitialized) {
setLoading(true)
const updatedNodes = nodes.map((node) => ({
...node,
hidden: hiddenNodeIds.includes(node.id),
}))

const updatedNodes = updateNodesHiddenState({
nodes,
hiddenNodeIds,
shouldHideGroupNodeId: !hasNonRelatedChildNodes(nodes),
})

const { nodes: highlightedNodes, edges: highlightedEdges } =
highlightNodesAndEdges(updatedNodes, getEdges(), {
Expand Down

0 comments on commit 5ce3616

Please sign in to comment.