From ffac92009d9cb96530d339b5b6d3f5f4d3fbf38d Mon Sep 17 00:00:00 2001 From: abdou6666 Date: Mon, 2 Dec 2024 15:00:17 +0100 Subject: [PATCH] fix: display sequence messages --- widget/src/providers/ChatProvider.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/widget/src/providers/ChatProvider.tsx b/widget/src/providers/ChatProvider.tsx index 3dd13cbc..d08c6f0a 100644 --- a/widget/src/providers/ChatProvider.tsx +++ b/widget/src/providers/ChatProvider.tsx @@ -249,7 +249,10 @@ const ChatProvider: React.FC<{ newIOMessage.delivery = true; } - setMessages([...messages, newIOMessage as TMessage]); + setMessages((prevMessages) => [ + ...prevMessages, + newIOMessage as TMessage, + ]); setScroll(0); } @@ -271,7 +274,8 @@ const ChatProvider: React.FC<{ } else { setSuggestions([]); } - isOpen || updateNewMessagesCount(newMessagesCount + 1); + isOpen || + updateNewMessagesCount((prevMessagesCount) => prevMessagesCount + 1); settings.alwaysScrollToBottom && setScroll(101); // @hack setOutgoingMessageState(OutgoingMessageState.sent); };