From 4f1277f912a6528f1283b8c47e1a0fd9a690f89f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 24 Aug 2022 00:06:45 +0200 Subject: [PATCH] Separate groups.delete event --- app/components/SocketProvider.tsx | 4 ++++ .../queues/processors/WebsocketsProcessor.ts | 23 +++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/components/SocketProvider.tsx b/app/components/SocketProvider.tsx index 76e3ca256..20feff2a2 100644 --- a/app/components/SocketProvider.tsx +++ b/app/components/SocketProvider.tsx @@ -246,6 +246,10 @@ class SocketProvider extends React.Component { } }); + this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => { + groups.remove(event.modelId); + }); + this.socket.on( "collections.delete", (event: WebsocketEntityDeletedEvent) => { diff --git a/server/queues/processors/WebsocketsProcessor.ts b/server/queues/processors/WebsocketsProcessor.ts index bcf96325b..1e2cf14aa 100644 --- a/server/queues/processors/WebsocketsProcessor.ts +++ b/server/queues/processors/WebsocketsProcessor.ts @@ -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: {