Skip to content

Commit

Permalink
fix(client): deduplicate node references in graph page #286 (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
duowb authored Mar 23, 2024
1 parent a1aeddf commit 6f4b22d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/client/src/composables/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,21 @@ export function parseGraphRawData(modules: ModuleInfo[], root: string) {
}

const uniqueDeps = getUniqueDeps(mod.deps, (dep) => {
node.edges.push(getEdge(mod.id, dep))
// save references
if (!moduleReferences.has(dep))
moduleReferences.set(dep, [])
moduleReferences.get(dep)!.push({
const moduleReferencesValue = moduleReferences.get(dep)!
const displayPath = removeRootPath(path)
const isExist = !!(moduleReferencesValue.find(item => item.path === path && item.displayPath === displayPath && item.mod.id === mod.id))
if (isExist)
return

moduleReferencesValue.push({
path,
displayPath: removeRootPath(path),
displayPath,
mod,
})
node.edges.push(getEdge(mod.id, dep))
})
mod.deps = uniqueDeps
graphNodesTotal.value.push(node)
Expand Down

0 comments on commit 6f4b22d

Please sign in to comment.