diff --git a/www/app/components/dashboard.js b/www/app/components/dashboard.js index d0b569ac..ef4ac5df 100644 --- a/www/app/components/dashboard.js +++ b/www/app/components/dashboard.js @@ -12,38 +12,59 @@ export function Dashboard({ stream, }) { const [openIndex, setOpenIndex] = useState(null); + const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); + + useEffect(() => { + if (autoscrollEnabled) scrollToBottom(); + }, [topics.length]); + + const scrollToBottom = () => { + const topicsDiv = document.getElementById("topics-div"); + topicsDiv.scrollTop = topicsDiv.scrollHeight; + }; + + const handleScroll = (e) => { + const bottom = e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight; + if (!bottom && autoscrollEnabled) { + setAutoscrollEnabled(false); + } else if (bottom && !autoscrollEnabled) { + setAutoscrollEnabled(true); + } + }; return ( <> -
Duration: {finalSummary.duration}
{finalSummary.summary}
@@ -61,7 +82,7 @@ export function Dashboard({ )}Capture The Signal, Not The Noise