From d3a3b9dbe6cf4f4ed27b6cc5a2dfbd7ef94d75bf Mon Sep 17 00:00:00 2001 From: 7w1 Date: Thu, 19 Mar 2026 21:39:37 -0500 Subject: [PATCH] reduce initial stutter --- src/app/features/room/RoomTimeline.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx index c5021c54..683b15d0 100644 --- a/src/app/features/room/RoomTimeline.tsx +++ b/src/app/features/room/RoomTimeline.tsx @@ -202,10 +202,13 @@ export function RoomTimeline({ const hasInitialScrolledRef = useRef(false); const currentRoomIdRef = useRef(room.roomId); + const [isReady, setIsReady] = useState(false); + if (currentRoomIdRef.current !== room.roomId) { hasInitialScrolledRef.current = false; mountScrollWindowRef.current = Date.now() + 3000; currentRoomIdRef.current = room.roomId; + setIsReady(false); } const processedEventsRef = useRef([]); @@ -275,6 +278,7 @@ export function RoomTimeline({ vListRef.current.scrollToIndex(processedEventsRef.current.length - 1, { align: 'end' }); const t = setTimeout(() => { vListRef.current?.scrollToIndex(processedEventsRef.current.length - 1, { align: 'end' }); + setIsReady(true); }, 80); hasInitialScrolledRef.current = true; return () => clearTimeout(t); @@ -694,7 +698,7 @@ export function RoomTimeline({ return ( - {unreadInfo?.readUptoEventId && !unreadInfo?.inLiveTimeline && ( + {unreadInfo?.readUptoEventId && !unreadInfo?.inLiveTimeline && isReady && ( ref={vListRef} @@ -832,7 +842,7 @@ export function RoomTimeline({ {frontPaginationJSX} - {!atBottomState && ( + {!atBottomState && isReady && (