Separate groups.delete event
This commit is contained in:
@@ -246,6 +246,10 @@ class SocketProvider extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => {
|
||||||
|
groups.remove(event.modelId);
|
||||||
|
});
|
||||||
|
|
||||||
this.socket.on(
|
this.socket.on(
|
||||||
"collections.delete",
|
"collections.delete",
|
||||||
(event: WebsocketEntityDeletedEvent) => {
|
(event: WebsocketEntityDeletedEvent) => {
|
||||||
|
|||||||
@@ -525,25 +525,14 @@ export default class WebsocketsProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "groups.delete": {
|
case "groups.delete": {
|
||||||
const group = await Group.findByPk(event.modelId, {
|
socketio.to(`team-${event.teamId}`).emit(event.name, {
|
||||||
paranoid: false,
|
modelId: event.modelId,
|
||||||
});
|
});
|
||||||
if (!group) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socketio.to(`team-${group.teamId}`).emit("entities", {
|
// we get users and collection relations that were just severed as a
|
||||||
event: event.name,
|
// result of the group deletion since there are cascading deletes, we
|
||||||
groupIds: [
|
// approximate this by looking for the recently deleted items in the
|
||||||
{
|
// GroupUser and CollectionGroup tables
|
||||||
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
|
|
||||||
const groupUsers = await GroupUser.findAll({
|
const groupUsers = await GroupUser.findAll({
|
||||||
paranoid: false,
|
paranoid: false,
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
Reference in New Issue
Block a user