Separate groups.delete event

This commit is contained in:
Tom Moor
2022-08-24 00:06:45 +02:00
parent b172da6fdf
commit 4f1277f912
2 changed files with 10 additions and 17 deletions

View File

@@ -246,6 +246,10 @@ class SocketProvider extends React.Component<Props> {
}
});
this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => {
groups.remove(event.modelId);
});
this.socket.on(
"collections.delete",
(event: WebsocketEntityDeletedEvent) => {

View File

@@ -525,25 +525,14 @@ export default class WebsocketsProcessor {
}
case "groups.delete": {
const group = await Group.findByPk(event.modelId, {
paranoid: false,
socketio.to(`team-${event.teamId}`).emit(event.name, {
modelId: event.modelId,
});
if (!group) {
return;
}
socketio.to(`team-${group.teamId}`).emit("entities", {
event: event.name,
groupIds: [
{
id: group.id,
updatedAt: group.updatedAt,
},
],
});
// we the users and collection relations that were just severed as a result of the group deletion
// since there are cascading deletes, we approximate this by looking for the recently deleted
// items in the GroupUser and CollectionGroup tables
// we get users and collection relations that were just severed as a
// result of the group deletion since there are cascading deletes, we
// approximate this by looking for the recently deleted items in the
// GroupUser and CollectionGroup tables
const groupUsers = await GroupUser.findAll({
paranoid: false,
where: {