use config to drive autoscroll state

This commit is contained in:
Alexey Bogomolov 2024-01-11 02:19:22 +03:00
parent e186e05c7d
commit 434abbc66f

View File

@ -379,12 +379,13 @@ function useScrollToBottom() {
// for auto-scroll
const scrollRef = useRef<HTMLDivElement>(null);
const [autoScroll, setAutoScroll] = useState(true);
const config = useAppConfig();
let isAutoScrollEnabled: boolean = config.autoScrollMessage;
function scrollDomToBottom() {
const dom = scrollRef.current;
if (dom) {
requestAnimationFrame(() => {
setAutoScroll(true);
setAutoScroll(isAutoScrollEnabled);
dom.scrollTo(0, dom.scrollHeight);
});
}