1
0
Fork 0
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:
Andrew Simachev 2025-06-03 11:27:24 +02:00
parent f96d815bed
commit a2c8e87363
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF

17
dist/workers/graph.js vendored
View file

@ -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++;
};
};