From 9c884af233cd2ab370f5e959cd1c95cd77d3ca46 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Wed, 4 Dec 2024 11:38:43 +0100 Subject: [PATCH] fix: synchronized sended messages for the same accounts --- api/src/chat/services/chat.service.ts | 5 +++++ widget/src/providers/ChatProvider.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/api/src/chat/services/chat.service.ts b/api/src/chat/services/chat.service.ts index bef07268..7e0a556a 100644 --- a/api/src/chat/services/chat.service.ts +++ b/api/src/chat/services/chat.service.ts @@ -253,6 +253,11 @@ export class ChatService { // Already existing user profile // Exec lastvisit hook this.eventEmitter.emit('hook:user:lastvisit', subscriber); + this.websocketGateway.broadcast( + subscriber, + event.getEventType(), + event._adapter.raw, + ); } this.websocketGateway.broadcastSubscriberUpdate(subscriber); diff --git a/widget/src/providers/ChatProvider.tsx b/widget/src/providers/ChatProvider.tsx index d08c6f0a..4796e3a8 100644 --- a/widget/src/providers/ChatProvider.tsx +++ b/widget/src/providers/ChatProvider.tsx @@ -250,7 +250,7 @@ const ChatProvider: React.FC<{ } setMessages((prevMessages) => [ - ...prevMessages, + ...prevMessages.filter((message) => message.mid !== newIOMessage.mid), newIOMessage as TMessage, ]); setScroll(0);