1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-10 18:10:54 +09:00

remove linked and related nodes with corresponding switches

This commit is contained in:
Andrew Simachev 2023-12-30 14:14:31 +01:00
parent d48c4dda3e
commit bd12a53be0
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8

12
dist/workers/graph.js vendored
View file

@ -217,11 +217,17 @@ updateForces = () => {
// Filter links
if (!settings.link) {
edges = edges.filter(d => d.type != EdgeType.Link);
updateOrphans();
nodes = nodes.filter(d => !d.linkCnt);
};
// Filter relations
if (!settings.relation) {
edges = edges.filter(d => d.type != EdgeType.Relation);
updateOrphans();
nodes = nodes.filter(d => !d.relationCnt);
};
// Filte local only edges
@ -305,7 +311,11 @@ updateTheme = ({ theme }) => {
updateOrphans = () => {
nodes = nodes.map(d => {
d.isOrphan = !!!edges.find(it => (it.source == d.id) || (it.target == d.id));
const edgeList = edges.filter(it => (it.source == d.id) || (it.target == d.id));
d.isOrphan = !edgeList.length;
d.linkCnt = edgeList.filter(it => it.type == EdgeType.Link).length;
d.relationCnt = edgeList.filter(it => it.type == EdgeType.Relation).length;
return d;
});
};