Skip to content

Commit e46e3e5

Browse files
committed
fixed disconnecting not connected group
1 parent 0a3f875 commit e46e3e5

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

public/js/elements/pipe.mjs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,32 @@ async function pipeEnd (d) {
148148
} else {
149149
console.log('no group to pipe to. Unlinking everything.');
150150
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
153153
const [ datum ] = d3.selectAll('div.group')
154154
.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+
}
173177
}
174178
}
175179
}

0 commit comments

Comments
 (0)