From ede20d2045bf54f51f69db3481f05d78d5c2b1d6 Mon Sep 17 00:00:00 2001 From: FanisNgv Date: Fri, 13 Sep 2024 18:30:05 +0300 Subject: [PATCH] sorting messages --- .../src/app/(withSidebar)/conversations/[id]/page.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/(withSidebar)/conversations/[id]/page.tsx b/frontend/src/app/(withSidebar)/conversations/[id]/page.tsx index c39a568..817f23e 100644 --- a/frontend/src/app/(withSidebar)/conversations/[id]/page.tsx +++ b/frontend/src/app/(withSidebar)/conversations/[id]/page.tsx @@ -80,8 +80,8 @@ export default function ConversationPage({ setMessage(""); }; - const isPendingRequest = currentConversation && - currentConversation.length > 0 && + const isPendingRequest = currentConversation && + currentConversation.length > 0 && currentConversation[currentConversation.length - 1].sender === "user" && currentConversation[currentConversation.length - 1].text !== null; @@ -120,7 +120,7 @@ export default function ConversationPage({ ...(isPendingRequest ? [{ id: Date.now(), text: "Ответ вот-вот будет...", sender: "bot" }] : []), - ]} + ].sort((a, b) => a.id - b.id)} />
@@ -147,4 +147,4 @@ export default function ConversationPage({
); -} +} \ No newline at end of file