prevent scroll from stopping above when decrypting messages change view

height
This commit is contained in:
Ajay Bura 2026-10-26 17:02:10 +05:30
commit cfde8f20ee
2 changed files with 6 additions and 4 deletions

View file

@ -201,6 +201,7 @@ export function RoomTimeline({ eventId, roomInputRef, editor, timeline }: RoomTi
const { markerTs } = useUnreadMarker(atBottomLazy, focused, readReceipt?.ts);
useTimelineContainerResizeStickBottom(
timeline,
getScrollElement,
useCallback(() => timelineContainerRef.current, []),
atBottomObservable,

View file

@ -178,6 +178,7 @@ export const useRestoreScrollToBottom = (
};
export const useTimelineContainerResizeStickBottom = (
timeline: TimelineView,
getScrollElement: () => HTMLElement | null,
getContainerElement: () => HTMLElement | null,
atBottomObservable: ObservableValue<boolean>,
@ -199,12 +200,12 @@ export const useTimelineContainerResizeStickBottom = (
if (!containerEntry || !scrollElement) return;
if (atBottomObservable.read) {
requestAnimationFrame(() => {
scrollToBottom(scrollElement, 'smooth');
});
const batchChange = timeline.batch.read.change;
const messageArrived = batchChange.type === 'Grow' && batchChange.dir === 'f';
scrollToBottom(scrollElement, messageArrived ? 'smooth' : 'instant');
}
};
}, [getContainerElement, getScrollElement, atBottomObservable]),
}, [timeline, getContainerElement, getScrollElement, atBottomObservable]),
enable ? getContainerElement : undefined
);
};