diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx index 04cddb32..617dac10 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx @@ -64,6 +64,7 @@ export default function TranscriptCorrect(details: TranscriptCorrect) { >, ]; transcriptId: string; + topicWithWordsLoading: boolean; }; export default function TopicHeader({ stateCurrentTopic, transcriptId, + topicWithWordsLoading, }: TopicHeader) { const [currentTopic, setCurrentTopic] = stateCurrentTopic; const topics = useTopics(transcriptId); @@ -32,10 +34,14 @@ export default function TopicHeader({ const total = topics.topics?.length; const canGoNext = total && typeof number == "number" && number + 1 < total; - const onPrev = () => + const onPrev = () => { + if (topicWithWordsLoading) return; canGoPrevious && setCurrentTopic(topics.topics?.at(number - 1)); - const onNext = () => + }; + const onNext = () => { + if (topicWithWordsLoading) return; canGoNext && setCurrentTopic(topics.topics?.at(number + 1)); + }; const keyHandler = (e) => { if (e.key == "ArrowLeft") { diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/topicPlayer.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/topicPlayer.tsx index 6aa5ad7f..30ad7392 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/topicPlayer.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/topicPlayer.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import useMp3 from "../../useMp3"; import { formatTime } from "../../../../lib/time"; import SoundWaveCss from "./soundWaveCss"; @@ -10,15 +10,18 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => { const [endSelectionCallback, setEndSelectionCallback] = useState<() => void>(); const [showTime, setShowTime] = useState(""); + const playButton = useRef(null); const keyHandler = (e) => { if (e.key == " ") { - if (isPlaying) { - mp3.media?.pause(); - setIsPlaying(false); - } else { - mp3.media?.play(); - setIsPlaying(true); + if (e.target.id != "playButton") { + if (isPlaying) { + mp3.media?.pause(); + setIsPlaying(false); + } else { + mp3.media?.play(); + setIsPlaying(true); + } } } else if (selectedTime && e.key == ",") { playSelection(); @@ -66,6 +69,7 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => { }, ); if (mp3.media && topicTime) { + playButton.current?.focus(); mp3.media?.pause(); // there's no callback on pause but apparently changing the time while palying doesn't work... so here is a timeout setTimeout(() => { @@ -166,7 +170,12 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => { )} {!isPlaying ? ( - + [SPACE] Play ) : ( diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx index 4f8eab42..f76f9012 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx @@ -151,7 +151,7 @@ const topicWords = ({ const getSpeakerName = (speakerNumber: number) => { if (!participants.response) return; return ( - (participants.response as Participant[]).find( + participants.response.find( (participant) => participant.speaker == speakerNumber, )?.name || `Speaker ${speakerNumber}` ); diff --git a/www/app/[domain]/transcripts/[transcriptId]/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/page.tsx index 9b06614b..a4a097a4 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/page.tsx @@ -92,6 +92,7 @@ export default function TranscriptDetails(details: TranscriptDetails) { topics={topics.topics || []} useActiveTopic={useActiveTopic} autoscroll={false} + transcriptId={transcriptId} /> diff --git a/www/app/[domain]/transcripts/topicList.tsx b/www/app/[domain]/transcripts/topicList.tsx index e7454f79..17b6e5a9 100644 --- a/www/app/[domain]/transcripts/topicList.tsx +++ b/www/app/[domain]/transcripts/topicList.tsx @@ -8,6 +8,7 @@ import { formatTime } from "../../lib/time"; import ScrollToBottom from "./scrollToBottom"; import { Topic } from "./webSocketTypes"; import { generateHighContrastColor } from "../../lib/utils"; +import useParticipants from "./useParticipants"; type TopicListProps = { topics: Topic[]; @@ -16,15 +17,18 @@ type TopicListProps = { React.Dispatch>, ]; autoscroll: boolean; + transcriptId: string; }; export function TopicList({ topics, useActiveTopic, autoscroll, + transcriptId, }: TopicListProps) { const [activeTopic, setActiveTopic] = useActiveTopic; const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); + const participants = useParticipants(transcriptId); useEffect(() => { if (autoscroll && autoscrollEnabled) scrollToBottom(); @@ -61,6 +65,15 @@ export function TopicList({ } }, [activeTopic, autoscroll]); + const getSpeakerName = (speakerNumber: number) => { + if (!participants.response) return; + return ( + participants.response.find( + (participant) => participant.speaker == speakerNumber, + )?.name || `Speaker ${speakerNumber}` + ); + }; + return ( {topics.length > 0 ? ( @@ -125,7 +138,7 @@ export function TopicList({ }} > {" "} - (Speaker {segment.speaker}): + {getSpeakerName(segment.speaker)}: {" "} {segment.text}