From 5d9067d3a7da86d7b884ca6c83709c735b8d18d7 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 2 Apr 2020 19:00:56 +0200 Subject: [PATCH] Update method --- src/controllers/UserWebSocketActions.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/controllers/UserWebSocketActions.ts b/src/controllers/UserWebSocketActions.ts index 2bf5621..003e14c 100644 --- a/src/controllers/UserWebSocketActions.ts +++ b/src/controllers/UserWebSocketActions.ts @@ -150,16 +150,11 @@ export class UserWebSocketActions { * @param c New comment */ public static async CreatedNewComment(c: Comment) { - - for(const client of UserWebSocketController.active_clients.filter((e) => e.registeredPosts.has(c.postID))) { - - UserWebSocketController.SendToClient(client, new WsMessage({ - id: "", - title: "new_comment", - data: await CommentsController.CommentToAPI(new AbritraryUserConnection(client.userID), c, true) - })) - - } + await UserWebSocketController.SendToSpecifcClients( + (e) => e.registeredPosts.has(c.postID), + async (client) => WsMessage.NoIDMessage("new_comment", + await CommentsController.CommentToAPI(new AbritraryUserConnection(client.userID), c, true)) + ) } /**