mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-09 09:35:02 +09:00
JS-4232: fix
This commit is contained in:
parent
2f8c78c28e
commit
2ec830ff2b
1 changed files with 21 additions and 9 deletions
30
dist/workers/graph.js
vendored
30
dist/workers/graph.js
vendored
|
@ -197,33 +197,41 @@ updateForces = () => {
|
|||
|
||||
// Filter links
|
||||
if (!settings.link) {
|
||||
nodes = nodes.filter(d => !d.linkCnt);
|
||||
edges = edges.filter(d => d.type != EdgeType.Link);
|
||||
|
||||
const ids = nodeIdsFromEdges(edges);
|
||||
nodes = nodes.filter(d => ids.has(d.id) || d.isOrphan);
|
||||
};
|
||||
|
||||
// Filter relations
|
||||
if (!settings.relation) {
|
||||
nodes = nodes.filter(d => !d.relationCnt);
|
||||
edges = edges.filter(d => d.type != EdgeType.Relation);
|
||||
|
||||
const ids = nodeIdsFromEdges(edges);
|
||||
nodes = nodes.filter(d => ids.has(d.id) || d.isOrphan);
|
||||
};
|
||||
|
||||
// Filte local only edges
|
||||
// Filter local only edges
|
||||
if (settings.local) {
|
||||
edges = getEdgesByNodeId(rootId);
|
||||
|
||||
const nodeIds = util.arrayUnique([ rootId ].concat(edges.map(d => d.source)).concat(edges.map(d => d.target)));
|
||||
nodes = nodes.filter(d => nodeIds.includes(d.id));
|
||||
};
|
||||
const ids = nodeIdsFromEdges(edges);
|
||||
ids.add(rootId);
|
||||
|
||||
let map = getNodeMap();
|
||||
edges = edges.filter(d => map.get(d.source) && map.get(d.target));
|
||||
nodes = nodes.filter(d => ids.has(d.id));
|
||||
};
|
||||
|
||||
// Filter orphans
|
||||
if (!settings.orphan) {
|
||||
nodes = nodes.filter(d => !d.isOrphan || d.forceShow);
|
||||
};
|
||||
|
||||
map = getNodeMap();
|
||||
let map = getNodeMap();
|
||||
edges = edges.filter(d => map.get(d.source) && map.get(d.target));
|
||||
|
||||
//map = getNodeMap();
|
||||
//edges = edges.filter(d => map.get(d.source) && map.get(d.target));
|
||||
|
||||
// Shallow copy to disable mutations
|
||||
nodes = nodes.map(d => {
|
||||
let o = old.get(d.id);
|
||||
|
@ -775,6 +783,10 @@ const getEdgesByNodeId = (id) => {
|
|||
return edges.filter(d => (d.source == id) || (d.target == id));
|
||||
};
|
||||
|
||||
const nodeIdsFromEdges = (edges) => {
|
||||
return new Set([].concat(edges.map(d => d.source)).concat(edges.map(d => d.target)));
|
||||
};
|
||||
|
||||
const getRadius = (d) => {
|
||||
let k = 1;
|
||||
if (settings.icon && images[d.src] && (transform.k >= transformThresholdHalf)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue