mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
fix(timeline): keep following the bottom when rows grow after rendering
This commit is contained in:
2 files changed
+22
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
# Keep following the timeline when a message grows after it renders
|
||||
@@ -769,6 +769,22 @@ export function RoomTimeline({
|
||||
return () => observer.disconnect();
|
||||
}, [syncAtBottom]);
|
||||
|
||||
// Decrypting rows and late-loading images grow without changing eventsLength,
|
||||
// so useTimelineSync's auto-scroll never re-fires for them.
|
||||
const lastScrollSizeRef = useRef(0);
|
||||
useLayoutEffect(() => {
|
||||
const v = vListRef.current;
|
||||
if (!v) return;
|
||||
|
||||
const grew = v.scrollSize > lastScrollSizeRef.current;
|
||||
lastScrollSizeRef.current = v.scrollSize;
|
||||
|
||||
if (!grew || !atBottomRef.current || !liveTimelineLinkedRef.current) return;
|
||||
|
||||
const lastIndex = processedEventsRef.current.length - 1;
|
||||
if (lastIndex >= 0) v.scrollToIndex(lastIndex, { align: 'end' });
|
||||
});
|
||||
|
||||
const actions = useTimelineActions({
|
||||
room,
|
||||
mx,
|
||||
@@ -1048,6 +1064,7 @@ export function RoomTimeline({
|
||||
|
||||
useEffect(() => {
|
||||
viewportFillCountRef.current = 0;
|
||||
lastScrollSizeRef.current = 0;
|
||||
}, [room.roomId]);
|
||||
|
||||
// Re-enters on every length change, so an unfillable viewport pages to the start of the
|
||||
|
||||
Reference in new issue
Block a user