File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
src/features/editor/views/GraphView/lib Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,31 @@ export function parser(jsonStr: string): Graph {
7373 }
7474 }
7575
76- states . graph . nodes = states . graph . nodes . map ( node => ( {
76+ // filter parent nodes that have no children
77+ // not the best way to do this, but it works
78+ const filteredNodes = states . graph . nodes . filter ( node => {
79+ if ( node . data . isParent && node . data . childrenCount === 0 ) {
80+ return false ;
81+ }
82+
83+ return true ;
84+ } ) ;
85+
86+ // add path to nodes
87+ states . graph . nodes = filteredNodes . map ( node => ( {
7788 ...node ,
7889 path : getNodePath ( states . graph . nodes , states . graph . edges , node . id ) ,
7990 } ) ) ;
8091
92+ // filter edges that have no from or to node (since we filtered empty parent nodes)
93+ states . graph . edges = states . graph . edges . filter ( edge => {
94+ const fromNode = states . graph . nodes . find ( node => node . id === edge . from ) ;
95+ const toNode = states . graph . nodes . find ( node => node . id === edge . to ) ;
96+
97+ if ( ! fromNode || ! toNode ) return false ;
98+ return true ;
99+ } ) ;
100+
81101 return states . graph ;
82102 } catch ( error ) {
83103 console . error ( error ) ;
You can’t perform that action at this time.
0 commit comments