fix: child monitors disappear after group deletion (#6287)

Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
pull/6295/head^2
Dorian Grasset 6 months ago committed by GitHub
parent a52186cf7e
commit 5207ba6d97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1060,6 +1060,27 @@ let needSetup = false;
const startTime = Date.now();
// Check if this is a group monitor and unlink children before deletion
const monitor = await R.findOne("monitor", " id = ? AND user_id = ? ", [
monitorID,
socket.userID,
]);
if (monitor && monitor.type === "group") {
// Get all children before unlinking them
const children = await Monitor.getChildren(monitorID);
// Unlink all children from the group
await Monitor.unlinkAllChildren(monitorID);
// Notify frontend to update each child monitor's parent to null
if (children && children.length > 0) {
for (const child of children) {
await server.sendUpdateMonitorIntoList(socket, child.id);
}
}
}
await R.exec("DELETE FROM monitor WHERE id = ? AND user_id = ? ", [
monitorID,
socket.userID,

Loading…
Cancel
Save