From 755a322e0808f8d11eb5499aa7a94be7b8d30a5e 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 | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/FloatingSupportChat/Chat.tsx b/src/components/FloatingSupportChat/Chat.tsx index 188ab27..1cc72bf 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,16 +249,22 @@ 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) { + + const last_message = messages[0].ticket_id === "111" ? messages[0] : messages[1] + + console.log("last_message") + console.log(last_message) + + if (((ticket.sessionData?.sessionId || user) !== last_message.user_id) && last_message.shown.me !== 1) { + shownMessage(last_message.id); + } + + console.log("user") console.log(user) console.log(messages[messages.length - 1]) - const newMessages = messages.filter(({ shown }) => shown.me !== 1); - - newMessages.map(async ({ id }) => { - await shownMessage(id); - }); } } }, [open, messages]); @@ -541,7 +547,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 (