Stay at bottom

This commit is contained in:
Bryan1029384756
2026-02-18 10:57:06 -06:00
parent e876ce5f9a
commit a9490f7bd4
2 changed files with 15 additions and 2 deletions

View File

@@ -8,9 +8,9 @@
- When resiszing the window and if im already at the bottom of the channel, i want to make sure i stay at the bottom of the channel.
<!-- - When resiszing the window and if im already at the bottom of the channel, i want to make sure i stay at the bottom of the channel.
- So right now in our search we can search and jump to messages. We can only jump to messages loaded in our chat already. How can we make it so we can jump to older messages not loaded in our chat at the moment?
- So right now in our search we can search and jump to messages. We can only jump to messages loaded in our chat already. How can we make it so we can jump to older messages not loaded in our chat at the moment? -->
- Are we using the encryped sql database to help load messages faster?

View File

@@ -1265,6 +1265,19 @@ const ChatArea = ({ channelId, channelName, channelType, username, channelKey, u
return () => scroller.removeEventListener('scroll', onScroll);
}, [scrollerElRef.current]);
// Keep scroll pinned to bottom when the scroll container resizes (e.g. window resize)
useEffect(() => {
const scroller = scrollerElRef.current;
if (!scroller) return;
const observer = new ResizeObserver(() => {
if (!userIsScrolledUpRef.current && !isInitialLoadRef.current) {
scroller.scrollTop = scroller.scrollHeight;
}
});
observer.observe(scroller);
return () => observer.disconnect();
}, [scrollerElRef.current]);
const saveSelection = () => {
const sel = window.getSelection();
if (sel.rangeCount > 0) savedRangeRef.current = sel.getRangeAt(0).cloneRange();