From f08ac64e452ea60a4f26843de7cd96f2d804256f Mon Sep 17 00:00:00 2001 From: Nastya Date: Mon, 12 May 2025 18:18:16 +0300 Subject: [PATCH] shown consultant to last message --- src/components/FloatingSupportChat/Chat.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/FloatingSupportChat/Chat.tsx b/src/components/FloatingSupportChat/Chat.tsx index 188ab27..cf4a8fd 100644 --- a/src/components/FloatingSupportChat/Chat.tsx +++ b/src/components/FloatingSupportChat/Chat.tsx @@ -205,7 +205,7 @@ export default function Chat({ open = false, onclickArrow, sx }: Props) { const message = getMessageFromFetchError(error); if (message) enqueueSnackbar(message); }, - onFetchStateChange: () => {}, + onFetchStateChange: () => { }, enabled: Boolean(user), }); @@ -249,15 +249,19 @@ export default function Chat({ open = false, onclickArrow, sx }: Props) { useEffect(() => { if (open) { - if (user !== undefined && messages.length > 1) { - console.log("SHOWN") + console.log("SHOWN") + if (messages.length > 1 && ((ticket.sessionData?.sessionId || user) !== messages[0].user_id) && messages[0].shown.me !== 1) { console.log("user") console.log(user) console.log(messages[messages.length - 1]) + + + shownMessage(messages[0].id); + const newMessages = messages.filter(({ shown }) => shown.me !== 1); newMessages.map(async ({ id }) => { - await shownMessage(id); + await shownMessage(messages[messages.length - 1].id); }); } } @@ -541,7 +545,7 @@ export default function Chat({ open = false, onclickArrow, sx }: Props) { console.log("message.user_id " + message.user_id) console.log("---------boolean result-----------") console.log((ticket.sessionData?.sessionId || user) === - message.user_id) + message.user_id) return (