From c9b9fcf63c93eccfd29c2103384bf360b142cd93 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 15 Oct 2024 18:23:03 -0300 Subject: [PATCH] fix: batch updates and scrolling issues (#4167) * use Flush instead of timeout to prevent batch updates * fix scroll while streaming * fix: Use setTimeout instead with flushSync for batch updates in buildUtils.ts * [autofix.ci] apply automated fixes * fix: Set selected view field when session is visible in IOModal * fix: Set selected view field when session is visible in IOModal * fix: Reset selected view field when closing IOModal * fix: Update date format in DateReader component - Pad hours, minutes, and seconds with leading zeros - Remove AM/PM from the formatted date - Use 24-hour format for hours in the formatted date fix: Update session ID generation in IOModal component - Remove AM/PM from the session ID format - Use 24-hour format for hours in the session ID --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/frontend/package-lock.json | 6 ------ .../src/components/dateReaderComponent/index.tsx | 9 +++------ .../components/chatView/chatMessage/index.tsx | 2 +- src/frontend/src/modals/IOModal/index.tsx | 9 ++++++++- src/frontend/src/stores/messagesStore.ts | 4 ++-- src/frontend/src/utils/buildUtils.ts | 12 +++++++----- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index d992f2475..5e9289b71 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -16296,12 +16296,6 @@ "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", "license": "MIT" }, - "node_modules/tinycolor2": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", - "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==", - "license": "MIT" - }, "node_modules/tmp": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", diff --git a/src/frontend/src/components/dateReaderComponent/index.tsx b/src/frontend/src/components/dateReaderComponent/index.tsx index 81c352f5a..6638641fd 100644 --- a/src/frontend/src/components/dateReaderComponent/index.tsx +++ b/src/frontend/src/components/dateReaderComponent/index.tsx @@ -9,13 +9,10 @@ export default function DateReader({ const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-indexed in JavaScript const day = String(date.getDate()).padStart(2, "0"); - const hours = date.getHours(); + const hours = String(date.getHours()).padStart(2, "0"); const minutes = String(date.getMinutes()).padStart(2, "0"); - - const ampm = hours >= 12 ? "PM" : "AM"; - const hours12 = hours > 12 ? hours - 12 : hours === 0 ? 12 : hours; // Convert to 12-hour format - - const formattedDate = `${year}-${month}-${day} ${hours12}:${minutes} ${ampm}`; + const seconds = String(date.getSeconds()).padStart(2, "0"); + const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; return {formattedDate}; } diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx index 8ddff615a..9c900bdf4 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx @@ -133,7 +133,7 @@ export default function ChatMessage({ }, 200); } } - }, [lastMessage]); + }, [lastMessage, chat]); let decodedMessage = chatMessage ?? ""; try { diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 9d8472442..d92a135b9 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -202,10 +202,16 @@ export default function IOModal({ useEffect(() => { if (!visibleSession) { setSessionId( - `Session ${new Date().toLocaleString("en-US", { day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit", hour12: true, second: "2-digit" })}`, + `Session ${new Date().toLocaleString("en-US", { day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit", hour12: false, second: "2-digit", timeZone: "UTC" })}`, ); } else if (visibleSession) { setSessionId(visibleSession); + if (selectedViewField?.type === "Session") { + setSelectedViewField({ + id: visibleSession, + type: "Session", + }); + } } }, [visibleSession]); @@ -437,6 +443,7 @@ export default function IOModal({