diff --git a/www/app/layout.tsx b/www/app/layout.tsx index 168ef820..de423da8 100644 --- a/www/app/layout.tsx +++ b/www/app/layout.tsx @@ -53,7 +53,7 @@ export const metadata: Metadata = { maximumScale: 1, }, - robots: { index: false, follow: false, noarchive: true, noimageindex: true } + robots: { index: false, follow: false, noarchive: true, noimageindex: true }, }; export default function RootLayout({ children }) { diff --git a/www/app/styles/globals.scss b/www/app/styles/globals.scss index 0acacc90..fcaea4b6 100644 --- a/www/app/styles/globals.scss +++ b/www/app/styles/globals.scss @@ -10,7 +10,7 @@ body { background: white; - scrollbar-color: rgb(96 165 250) transparent; + scrollbar-color: rgb(132, 186, 251) transparent; scrollbar-width: thin; } @@ -26,12 +26,11 @@ body { } ::-webkit-scrollbar { - visibility: visible; width: 5px; opacity: 0.7; } ::-webkit-scrollbar-thumb { border-radius: 10px; - background-color: rgb(96 165 250); + background-color: rgb(132, 186, 251); } diff --git a/www/app/transcripts/[transcriptId]/page.tsx b/www/app/transcripts/[transcriptId]/page.tsx index 967eab12..17cee689 100644 --- a/www/app/transcripts/[transcriptId]/page.tsx +++ b/www/app/transcripts/[transcriptId]/page.tsx @@ -52,6 +52,7 @@ export default function TranscriptDetails(details: TranscriptDetails) { diff --git a/www/app/transcripts/new/page.tsx b/www/app/transcripts/new/page.tsx index 15ce5ca9..07a0b8b9 100644 --- a/www/app/transcripts/new/page.tsx +++ b/www/app/transcripts/new/page.tsx @@ -65,6 +65,7 @@ const TranscriptCreate = () => { {!hasRecorded ? ( diff --git a/www/app/transcripts/scrollToBottom.tsx b/www/app/transcripts/scrollToBottom.tsx index a702ede9..8088709c 100644 --- a/www/app/transcripts/scrollToBottom.tsx +++ b/www/app/transcripts/scrollToBottom.tsx @@ -9,15 +9,15 @@ type ScrollToBottomProps = { export default function ScrollToBottom(props: ScrollToBottomProps) { return ( { props.handleScrollBottom(); return false; }} > - + ); } diff --git a/www/app/transcripts/topicList.tsx b/www/app/transcripts/topicList.tsx index 02bba6f7..65a76276 100644 --- a/www/app/transcripts/topicList.tsx +++ b/www/app/transcripts/topicList.tsx @@ -14,43 +14,62 @@ type TopicListProps = { Topic | null, React.Dispatch>, ]; + autoscroll: boolean; }; -export function TopicList({ topics, useActiveTopic }: TopicListProps) { +export function TopicList({ + topics, + useActiveTopic, + autoscroll, +}: TopicListProps) { const [activeTopic, setActiveTopic] = useActiveTopic; const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); useEffect(() => { - if (autoscrollEnabled) scrollToBottom(); - console.log(topics); + if (autoscroll && autoscrollEnabled) scrollToBottom(); }, [topics.length]); const scrollToBottom = () => { const topicsDiv = document.getElementById("topics-div"); - if (!topicsDiv) - console.error("Could not find topics div to scroll to bottom"); - else topicsDiv.scrollTop = topicsDiv.scrollHeight; + if (topicsDiv) topicsDiv.scrollTop = topicsDiv.scrollHeight; }; - const handleScroll = (e) => { + // scroll top is not rounded, heights are, so exact match won't work. + // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#determine_if_an_element_has_been_totally_scrolled + const toggleScroll = (element) => { const bottom = - e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight; + Math.abs( + element.scrollHeight - element.clientHeight - element.scrollTop, + ) < 2 || element.scrollHeight == element.clientHeight; if (!bottom && autoscrollEnabled) { setAutoscrollEnabled(false); } else if (bottom && !autoscrollEnabled) { setAutoscrollEnabled(true); } }; + const handleScroll = (e) => { + toggleScroll(e.target); + }; + + useEffect(() => { + if (autoscroll) { + const topicsDiv = document.getElementById("topics-div"); + + topicsDiv && toggleScroll(topicsDiv); + } + }, [activeTopic, autoscroll]); return ( {topics.length > 0 ? ( <> - + {autoscroll && ( + + )} ( setActiveTopic(activeTopic?.id == topic.id ? null : topic) } diff --git a/www/app/transcripts/useWebSockets.ts b/www/app/transcripts/useWebSockets.ts index 07c7545c..51ae92eb 100644 --- a/www/app/transcripts/useWebSockets.ts +++ b/www/app/transcripts/useWebSockets.ts @@ -65,6 +65,58 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { }, ]); + setFinalSummary({ summary: "This is the final summary" }); + } + if (e.key === "z" && process.env.NEXT_PUBLIC_ENV === "development") { + setTranscriptText( + "This text is in English, and it is a pretty long sentence to test the limits", + ); + setTopics([ + { + id: "1", + timestamp: 10, + summary: "This is test topic 1", + title: + "Topic 1: Introduction to Quantum Mechanics, a brief overview of quantum mechanics and its principles.", + transcript: + "A brief overview of quantum mechanics and its principles.", + }, + { + id: "2", + timestamp: 20, + summary: "This is test topic 2", + title: + "Topic 2: Machine Learning Algorithms, understanding the different types of machine learning algorithms.", + transcript: + "Understanding the different types of machine learning algorithms.", + }, + { + id: "3", + timestamp: 30, + summary: "This is test topic 3", + title: + "Topic 3: Mental Health Awareness, ways to improve mental health and reduce stigma.", + transcript: "Ways to improve mental health and reduce stigma.", + }, + { + id: "4", + timestamp: 40, + summary: "This is test topic 4", + title: + "Topic 4: Basics of Productivity, tips and tricks to increase daily productivity.", + transcript: "Tips and tricks to increase daily productivity.", + }, + { + id: "5", + timestamp: 50, + summary: "This is test topic 5", + title: + "Topic 5: Future of Aviation, exploring the advancements and possibilities in aviation.", + transcript: + "Exploring the advancements and possibilities in aviation.", + }, + ]); + setFinalSummary({ summary: "This is the final summary" }); } };