@@ -148,28 +148,32 @@ async function pipeEnd (d) {
148
148
} else {
149
149
console . log ( 'no group to pipe to. Unlinking everything.' ) ;
150
150
const to = id ;
151
- await DELETE ( `/removePipe?to= ${ to } ` ) ;
152
- // UPDATE THE FRONT END
151
+ // TO DO: FIX THIS
152
+ // GET THE GROUP THE CURRENT SELECTION IS PIPED TO
153
153
const [ datum ] = d3 . selectAll ( 'div.group' )
154
154
. filter ( d => d . pipe_to . includes ( to ) ) . data ( ) ;
155
- let { id : from , pipe_to } = datum || { } ;
156
- pipe_to = pipe_to . filter ( d => d !== to ) ;
157
- // UPDATE THE PIPED GROUP
158
- await Group . update ( {
159
- datum : { id : from , pipe_to } ,
160
- bcast : true ,
161
- } ) ;
162
- // UPDATE THE PIPED NOTES
163
- const note_pipes = d3 . selectAll ( 'div.note' )
164
- . filter ( d => tree . hasNode ( d . tree , to ) ) ;
165
- if ( note_pipes . size ( ) ) {
166
- const notes = [ ...note_pipes . nodes ( ) ] ;
167
- for ( let n = 0 ; n < notes . length ; n ++ ) {
168
- await Note . update ( {
169
- note : d3 . select ( notes [ n ] ) ,
170
- datum : { pipe_from : null } ,
171
- bcast : true ,
172
- } ) ;
155
+ if ( datum !== undefined ) {
156
+ await DELETE ( `/removePipe?to=${ to } ` ) ;
157
+ // UPDATE THE FRONT END
158
+ let { id : from , pipe_to } = datum || { } ;
159
+ pipe_to = pipe_to . filter ( d => d !== to ) ;
160
+ // UPDATE THE PIPED GROUP
161
+ await Group . update ( {
162
+ datum : { id : from , pipe_to } ,
163
+ bcast : true ,
164
+ } ) ;
165
+ // UPDATE THE PIPED NOTES
166
+ const note_pipes = d3 . selectAll ( 'div.note' )
167
+ . filter ( d => tree . hasNode ( d . tree , to ) ) ;
168
+ if ( note_pipes . size ( ) ) {
169
+ const notes = [ ...note_pipes . nodes ( ) ] ;
170
+ for ( let n = 0 ; n < notes . length ; n ++ ) {
171
+ await Note . update ( {
172
+ note : d3 . select ( notes [ n ] ) ,
173
+ datum : { pipe_from : null } ,
174
+ bcast : true ,
175
+ } ) ;
176
+ }
173
177
}
174
178
}
175
179
}
0 commit comments