mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
final adjustments
This commit is contained in:
@@ -64,6 +64,7 @@ export default function TranscriptCorrect(details: TranscriptCorrect) {
|
|||||||
<TopicHeader
|
<TopicHeader
|
||||||
stateCurrentTopic={stateCurrentTopic}
|
stateCurrentTopic={stateCurrentTopic}
|
||||||
transcriptId={transcriptId}
|
transcriptId={transcriptId}
|
||||||
|
topicWithWordsLoading={topicWithWords.loading}
|
||||||
/>
|
/>
|
||||||
<TopicWords
|
<TopicWords
|
||||||
stateSelectedText={stateSelectedText}
|
stateSelectedText={stateSelectedText}
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ type TopicHeader = {
|
|||||||
Dispatch<SetStateAction<GetTranscriptTopic | undefined>>,
|
Dispatch<SetStateAction<GetTranscriptTopic | undefined>>,
|
||||||
];
|
];
|
||||||
transcriptId: string;
|
transcriptId: string;
|
||||||
|
topicWithWordsLoading: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function TopicHeader({
|
export default function TopicHeader({
|
||||||
stateCurrentTopic,
|
stateCurrentTopic,
|
||||||
transcriptId,
|
transcriptId,
|
||||||
|
topicWithWordsLoading,
|
||||||
}: TopicHeader) {
|
}: TopicHeader) {
|
||||||
const [currentTopic, setCurrentTopic] = stateCurrentTopic;
|
const [currentTopic, setCurrentTopic] = stateCurrentTopic;
|
||||||
const topics = useTopics(transcriptId);
|
const topics = useTopics(transcriptId);
|
||||||
@@ -32,10 +34,14 @@ export default function TopicHeader({
|
|||||||
const total = topics.topics?.length;
|
const total = topics.topics?.length;
|
||||||
const canGoNext = total && typeof number == "number" && number + 1 < total;
|
const canGoNext = total && typeof number == "number" && number + 1 < total;
|
||||||
|
|
||||||
const onPrev = () =>
|
const onPrev = () => {
|
||||||
|
if (topicWithWordsLoading) return;
|
||||||
canGoPrevious && setCurrentTopic(topics.topics?.at(number - 1));
|
canGoPrevious && setCurrentTopic(topics.topics?.at(number - 1));
|
||||||
const onNext = () =>
|
};
|
||||||
|
const onNext = () => {
|
||||||
|
if (topicWithWordsLoading) return;
|
||||||
canGoNext && setCurrentTopic(topics.topics?.at(number + 1));
|
canGoNext && setCurrentTopic(topics.topics?.at(number + 1));
|
||||||
|
};
|
||||||
|
|
||||||
const keyHandler = (e) => {
|
const keyHandler = (e) => {
|
||||||
if (e.key == "ArrowLeft") {
|
if (e.key == "ArrowLeft") {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import useMp3 from "../../useMp3";
|
import useMp3 from "../../useMp3";
|
||||||
import { formatTime } from "../../../../lib/time";
|
import { formatTime } from "../../../../lib/time";
|
||||||
import SoundWaveCss from "./soundWaveCss";
|
import SoundWaveCss from "./soundWaveCss";
|
||||||
@@ -10,15 +10,18 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => {
|
|||||||
const [endSelectionCallback, setEndSelectionCallback] =
|
const [endSelectionCallback, setEndSelectionCallback] =
|
||||||
useState<() => void>();
|
useState<() => void>();
|
||||||
const [showTime, setShowTime] = useState("");
|
const [showTime, setShowTime] = useState("");
|
||||||
|
const playButton = useRef<HTMLButtonElement>(null);
|
||||||
|
|
||||||
const keyHandler = (e) => {
|
const keyHandler = (e) => {
|
||||||
if (e.key == " ") {
|
if (e.key == " ") {
|
||||||
if (isPlaying) {
|
if (e.target.id != "playButton") {
|
||||||
mp3.media?.pause();
|
if (isPlaying) {
|
||||||
setIsPlaying(false);
|
mp3.media?.pause();
|
||||||
} else {
|
setIsPlaying(false);
|
||||||
mp3.media?.play();
|
} else {
|
||||||
setIsPlaying(true);
|
mp3.media?.play();
|
||||||
|
setIsPlaying(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (selectedTime && e.key == ",") {
|
} else if (selectedTime && e.key == ",") {
|
||||||
playSelection();
|
playSelection();
|
||||||
@@ -66,6 +69,7 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (mp3.media && topicTime) {
|
if (mp3.media && topicTime) {
|
||||||
|
playButton.current?.focus();
|
||||||
mp3.media?.pause();
|
mp3.media?.pause();
|
||||||
// there's no callback on pause but apparently changing the time while palying doesn't work... so here is a timeout
|
// there's no callback on pause but apparently changing the time while palying doesn't work... so here is a timeout
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -166,7 +170,12 @@ const TopicPlayer = ({ transcriptId, selectedTime, topicTime }) => {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{!isPlaying ? (
|
{!isPlaying ? (
|
||||||
<button className="p-2 bg-blue-200 w-full" onClick={playCurrent}>
|
<button
|
||||||
|
ref={playButton}
|
||||||
|
id="playButton"
|
||||||
|
className="p-2 bg-blue-200 w-full"
|
||||||
|
onClick={playCurrent}
|
||||||
|
>
|
||||||
<span className="text-xs">[SPACE]</span> Play
|
<span className="text-xs">[SPACE]</span> Play
|
||||||
</button>
|
</button>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ const topicWords = ({
|
|||||||
const getSpeakerName = (speakerNumber: number) => {
|
const getSpeakerName = (speakerNumber: number) => {
|
||||||
if (!participants.response) return;
|
if (!participants.response) return;
|
||||||
return (
|
return (
|
||||||
(participants.response as Participant[]).find(
|
participants.response.find(
|
||||||
(participant) => participant.speaker == speakerNumber,
|
(participant) => participant.speaker == speakerNumber,
|
||||||
)?.name || `Speaker ${speakerNumber}`
|
)?.name || `Speaker ${speakerNumber}`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
|||||||
topics={topics.topics || []}
|
topics={topics.topics || []}
|
||||||
useActiveTopic={useActiveTopic}
|
useActiveTopic={useActiveTopic}
|
||||||
autoscroll={false}
|
autoscroll={false}
|
||||||
|
transcriptId={transcriptId}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="w-full h-full grid grid-rows-layout-one grid-cols-1 gap-2 lg:gap-4">
|
<div className="w-full h-full grid grid-rows-layout-one grid-cols-1 gap-2 lg:gap-4">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { formatTime } from "../../lib/time";
|
|||||||
import ScrollToBottom from "./scrollToBottom";
|
import ScrollToBottom from "./scrollToBottom";
|
||||||
import { Topic } from "./webSocketTypes";
|
import { Topic } from "./webSocketTypes";
|
||||||
import { generateHighContrastColor } from "../../lib/utils";
|
import { generateHighContrastColor } from "../../lib/utils";
|
||||||
|
import useParticipants from "./useParticipants";
|
||||||
|
|
||||||
type TopicListProps = {
|
type TopicListProps = {
|
||||||
topics: Topic[];
|
topics: Topic[];
|
||||||
@@ -16,15 +17,18 @@ type TopicListProps = {
|
|||||||
React.Dispatch<React.SetStateAction<Topic | null>>,
|
React.Dispatch<React.SetStateAction<Topic | null>>,
|
||||||
];
|
];
|
||||||
autoscroll: boolean;
|
autoscroll: boolean;
|
||||||
|
transcriptId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TopicList({
|
export function TopicList({
|
||||||
topics,
|
topics,
|
||||||
useActiveTopic,
|
useActiveTopic,
|
||||||
autoscroll,
|
autoscroll,
|
||||||
|
transcriptId,
|
||||||
}: TopicListProps) {
|
}: TopicListProps) {
|
||||||
const [activeTopic, setActiveTopic] = useActiveTopic;
|
const [activeTopic, setActiveTopic] = useActiveTopic;
|
||||||
const [autoscrollEnabled, setAutoscrollEnabled] = useState<boolean>(true);
|
const [autoscrollEnabled, setAutoscrollEnabled] = useState<boolean>(true);
|
||||||
|
const participants = useParticipants(transcriptId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (autoscroll && autoscrollEnabled) scrollToBottom();
|
if (autoscroll && autoscrollEnabled) scrollToBottom();
|
||||||
@@ -61,6 +65,15 @@ export function TopicList({
|
|||||||
}
|
}
|
||||||
}, [activeTopic, autoscroll]);
|
}, [activeTopic, autoscroll]);
|
||||||
|
|
||||||
|
const getSpeakerName = (speakerNumber: number) => {
|
||||||
|
if (!participants.response) return;
|
||||||
|
return (
|
||||||
|
participants.response.find(
|
||||||
|
(participant) => participant.speaker == speakerNumber,
|
||||||
|
)?.name || `Speaker ${speakerNumber}`
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="relative w-full h-full bg-blue-400/20 rounded-lg md:rounded-xl p-1 sm:p-2 md:px-4 flex flex-col justify-center align-center">
|
<section className="relative w-full h-full bg-blue-400/20 rounded-lg md:rounded-xl p-1 sm:p-2 md:px-4 flex flex-col justify-center align-center">
|
||||||
{topics.length > 0 ? (
|
{topics.length > 0 ? (
|
||||||
@@ -125,7 +138,7 @@ export function TopicList({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{" "}
|
{" "}
|
||||||
(Speaker {segment.speaker}):
|
{getSpeakerName(segment.speaker)}:
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
<span>{segment.text}</span>
|
<span>{segment.text}</span>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user