From 27ff214d04fdddaa82052c21c0c80f6d717cf833 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Sun, 2 Feb 2025 09:59:23 -0800 Subject: [PATCH] ChatDrawer: sync once a minute so we don't get unexpected regroup flashes --- .../layout-drawer/useChatDrawerRenderItems.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/apps/chat/components/layout-drawer/useChatDrawerRenderItems.tsx b/src/apps/chat/components/layout-drawer/useChatDrawerRenderItems.tsx index 9208e20d18..61e0911101 100644 --- a/src/apps/chat/components/layout-drawer/useChatDrawerRenderItems.tsx +++ b/src/apps/chat/components/layout-drawer/useChatDrawerRenderItems.tsx @@ -91,6 +91,17 @@ export function useChatDrawerRenderItems( searchDepth: ChatSearchDepth, ): ChatDrawerRenderItems { + // state + const [_, setJustAMinuteCounter] = React.useState(0); + + + // [effect] Refresh every minute because the `getTimeBucketEn` function uses the current time + React.useEffect(() => { + const interval = setInterval(() => setJustAMinuteCounter(c => c + 1), 60 * 1000); + return () => clearInterval(interval); + }, []); + + const stabilizeRenderItems = React.useRef(); return useChatStore(({ conversations }) => {