mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-07 21:47:02 +09:00
code review
This commit is contained in:
parent
f96d815bed
commit
a2c8e87363
1 changed files with 9 additions and 8 deletions
17
dist/workers/graph.js
vendored
17
dist/workers/graph.js
vendored
|
@ -392,23 +392,24 @@ getEdgeMap = () => {
|
|||
* Updates orphan status and degree counts for all nodes.
|
||||
*/
|
||||
updateOrphans = () => {
|
||||
// Build a map of nodeId -> edges for efficient lookup
|
||||
const nodeEdgeMap = getEdgeMap();
|
||||
const edgeMap = getEdgeMap();
|
||||
|
||||
// Update nodes using the map
|
||||
nodes = nodes.map(d => {
|
||||
const nodeEdges = nodeEdgeMap.get(d.id) || [];
|
||||
const edges = edgeMap.get(d.id) || [];
|
||||
|
||||
d.isOrphan = nodeEdges.length === 0;
|
||||
d.isOrphan = !edges.length;
|
||||
d.linkCnt = 0;
|
||||
d.relationCnt = 0;
|
||||
|
||||
for (let i = 0; i < nodeEdges.length; i++) {
|
||||
if (nodeEdges[i].type == EdgeType.Link) {
|
||||
d.linkCnt++;
|
||||
for (let i = 0; i < edges.length; i++) {
|
||||
const t = edges[i].type;
|
||||
|
||||
if (t == EdgeType.Link) {
|
||||
d.linkCnt++;
|
||||
};
|
||||
|
||||
if (nodeEdges[i].type == EdgeType.Relation) {
|
||||
if (t == EdgeType.Relation) {
|
||||
d.relationCnt++;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue