mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-23 05:39:05 +00:00
Merge branch 'main' of github.com:Monadical-SAS/reflector into sara/feat-speaker-reassign
This commit is contained in:
@@ -8,7 +8,7 @@ import useTopicWithWords from "../../useTopicWithWords";
|
||||
import ParticipantList from "./participantList";
|
||||
import { GetTranscriptTopic } from "../../../../api";
|
||||
import { SelectedText, selectedTextIsTimeSlice } from "./types";
|
||||
import getApi from "../../../../lib/getApi";
|
||||
import useApi from "../../../../lib/useApi";
|
||||
import useTranscript from "../../useTranscript";
|
||||
import { useError } from "../../../../(errors)/errorContext";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -23,7 +23,7 @@ export type TranscriptCorrect = {
|
||||
export default function TranscriptCorrect({
|
||||
params: { transcriptId },
|
||||
}: TranscriptCorrect) {
|
||||
const api = getApi();
|
||||
const api = useApi();
|
||||
const transcript = useTranscript(transcriptId);
|
||||
const stateCurrentTopic = useState<GetTranscriptTopic>();
|
||||
const [currentTopic, _sct] = stateCurrentTopic;
|
||||
@@ -37,10 +37,7 @@ export default function TranscriptCorrect({
|
||||
const markAsDone = () => {
|
||||
if (transcript.response && !transcript.response.reviewed) {
|
||||
api
|
||||
?.v1TranscriptUpdate({
|
||||
transcriptId,
|
||||
updateTranscript: { reviewed: true },
|
||||
})
|
||||
?.v1TranscriptUpdate(transcriptId, { reviewed: true })
|
||||
.then(() => {
|
||||
router.push(`/transcripts/${transcriptId}`);
|
||||
})
|
||||
@@ -75,7 +72,7 @@ export default function TranscriptCorrect({
|
||||
currentTopic
|
||||
? {
|
||||
start: currentTopic?.timestamp,
|
||||
end: currentTopic?.timestamp + currentTopic?.duration,
|
||||
end: currentTopic?.timestamp + (currentTopic?.duration || 0),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { faArrowTurnDown, faSpinner } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { ChangeEvent, useEffect, useRef, useState } from "react";
|
||||
import { Participant } from "../../../../api";
|
||||
import getApi from "../../../../lib/getApi";
|
||||
import useApi from "../../../../lib/useApi";
|
||||
import { UseParticipants } from "../../useParticipants";
|
||||
import { selectedTextIsSpeaker, selectedTextIsTimeSlice } from "./types";
|
||||
import { useError } from "../../../../(errors)/errorContext";
|
||||
@@ -31,7 +31,7 @@ const ParticipantList = ({
|
||||
topicWithWords,
|
||||
stateSelectedText,
|
||||
}: ParticipantList) => {
|
||||
const api = getApi();
|
||||
const api = useApi();
|
||||
const { setError } = useError();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [participantInput, setParticipantInput] = useState("");
|
||||
@@ -123,13 +123,10 @@ const ParticipantList = ({
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
await api?.v1TranscriptAssignSpeaker({
|
||||
speakerAssignment: {
|
||||
participant: participant.id,
|
||||
timestampFrom: selectedText.start,
|
||||
timestampTo: selectedText.end,
|
||||
},
|
||||
transcriptId,
|
||||
await api?.v1TranscriptAssignSpeaker(transcriptId, {
|
||||
participant: participant.id,
|
||||
timestamp_from: selectedText.start,
|
||||
timestamp_to: selectedText.end,
|
||||
});
|
||||
onSuccess();
|
||||
} catch (error) {
|
||||
@@ -145,12 +142,9 @@ const ParticipantList = ({
|
||||
setLoading(true);
|
||||
if (participantTo.speaker) {
|
||||
try {
|
||||
await api?.v1TranscriptMergeSpeaker({
|
||||
transcriptId,
|
||||
speakerMerge: {
|
||||
speakerFrom: speakerFrom,
|
||||
speakerTo: participantTo.speaker,
|
||||
},
|
||||
await api?.v1TranscriptMergeSpeaker(transcriptId, {
|
||||
speaker_from: speakerFrom,
|
||||
speaker_to: participantTo.speaker,
|
||||
});
|
||||
onSuccess();
|
||||
} catch (error) {
|
||||
@@ -159,11 +153,11 @@ const ParticipantList = ({
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await api?.v1TranscriptUpdateParticipant({
|
||||
await api?.v1TranscriptUpdateParticipant(
|
||||
transcriptId,
|
||||
participantId: participantTo.id,
|
||||
updateParticipant: { speaker: speakerFrom },
|
||||
});
|
||||
participantTo.id,
|
||||
{ speaker: speakerFrom },
|
||||
);
|
||||
onSuccess();
|
||||
} catch (error) {
|
||||
setError(error, "There was an error merging (update)");
|
||||
@@ -189,12 +183,8 @@ const ParticipantList = ({
|
||||
if (participant && participant.name !== participantInput) {
|
||||
setLoading(true);
|
||||
api
|
||||
?.v1TranscriptUpdateParticipant({
|
||||
participantId: participant.id,
|
||||
transcriptId,
|
||||
updateParticipant: {
|
||||
name: participantInput,
|
||||
},
|
||||
?.v1TranscriptUpdateParticipant(participant.id, transcriptId, {
|
||||
name: participantInput,
|
||||
})
|
||||
.then(() => {
|
||||
participants.refetch();
|
||||
@@ -212,12 +202,9 @@ const ParticipantList = ({
|
||||
) {
|
||||
setLoading(true);
|
||||
api
|
||||
?.v1TranscriptAddParticipant({
|
||||
createParticipant: {
|
||||
name: participantInput,
|
||||
speaker: selectedText,
|
||||
},
|
||||
transcriptId,
|
||||
?.v1TranscriptAddParticipant(transcriptId, {
|
||||
name: participantInput,
|
||||
speaker: selectedText,
|
||||
})
|
||||
.then(() => {
|
||||
participants.refetch();
|
||||
@@ -235,12 +222,12 @@ const ParticipantList = ({
|
||||
) {
|
||||
setLoading(true);
|
||||
try {
|
||||
const participant = await api?.v1TranscriptAddParticipant({
|
||||
createParticipant: {
|
||||
const participant = await api?.v1TranscriptAddParticipant(
|
||||
transcriptId,
|
||||
{
|
||||
name: participantInput,
|
||||
},
|
||||
transcriptId,
|
||||
});
|
||||
);
|
||||
setLoading(false);
|
||||
assignTo(participant)().catch(() => {
|
||||
// error and loading are handled by assignTo catch
|
||||
@@ -253,11 +240,8 @@ const ParticipantList = ({
|
||||
} else if (action == "Create") {
|
||||
setLoading(true);
|
||||
api
|
||||
?.v1TranscriptAddParticipant({
|
||||
createParticipant: {
|
||||
name: participantInput,
|
||||
},
|
||||
transcriptId,
|
||||
?.v1TranscriptAddParticipant(transcriptId, {
|
||||
name: participantInput,
|
||||
})
|
||||
.then(() => {
|
||||
participants.refetch();
|
||||
@@ -277,10 +261,7 @@ const ParticipantList = ({
|
||||
if (loading || participants.loading || topicWithWords.loading) return;
|
||||
setLoading(true);
|
||||
api
|
||||
?.v1TranscriptDeleteParticipant({
|
||||
transcriptId,
|
||||
participantId,
|
||||
})
|
||||
?.v1TranscriptDeleteParticipant(transcriptId, participantId)
|
||||
.then(() => {
|
||||
participants.refetch();
|
||||
setLoading(false);
|
||||
|
||||
@@ -9,9 +9,7 @@ import {
|
||||
Kbd,
|
||||
Skeleton,
|
||||
SkeletonCircle,
|
||||
chakra,
|
||||
Flex,
|
||||
Center,
|
||||
} from "@chakra-ui/react";
|
||||
import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons";
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
WrapItem,
|
||||
Kbd,
|
||||
Skeleton,
|
||||
chakra,
|
||||
} from "@chakra-ui/react";
|
||||
|
||||
type TopicPlayer = {
|
||||
|
||||
@@ -3,14 +3,7 @@ import WaveformLoading from "../../waveformLoading";
|
||||
import { UseParticipants } from "../../useParticipants";
|
||||
import { UseTopicWithWords } from "../../useTopicWithWords";
|
||||
import { TimeSlice, selectedTextIsTimeSlice } from "./types";
|
||||
import {
|
||||
BoxProps,
|
||||
Box,
|
||||
Container,
|
||||
Text,
|
||||
chakra,
|
||||
Spinner,
|
||||
} from "@chakra-ui/react";
|
||||
import { BoxProps, Box, Container, Text, Spinner } from "@chakra-ui/react";
|
||||
|
||||
type TopicWordsProps = {
|
||||
stateSelectedText: [
|
||||
@@ -167,7 +160,7 @@ const topicWords = ({
|
||||
maxW={{ lg: "container.md" }}
|
||||
{...chakraProps}
|
||||
>
|
||||
{topicWithWords.response.wordsPerSpeaker.map(
|
||||
{topicWithWords.response.words_per_speaker?.map(
|
||||
(speakerWithWords, index) => (
|
||||
<Text key={index} className="mb-2 last:mb-0">
|
||||
<Box
|
||||
|
||||
@@ -17,6 +17,7 @@ import Player from "../player";
|
||||
import WaveformLoading from "../waveformLoading";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { featureEnabled } from "../../domainContext";
|
||||
import { toShareMode } from "../../../lib/shareMode";
|
||||
|
||||
type TranscriptDetails = {
|
||||
params: {
|
||||
@@ -37,7 +38,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
||||
|
||||
useEffect(() => {
|
||||
const statusToRedirect = ["idle", "recording", "processing"];
|
||||
if (statusToRedirect.includes(transcript.response?.status)) {
|
||||
if (statusToRedirect.includes(transcript.response?.status || "")) {
|
||||
const newUrl = "/transcripts/" + details.params.transcriptId + "/record";
|
||||
// Shallow redirection does not work on NextJS 13
|
||||
// https://github.com/vercel/next.js/discussions/48110
|
||||
@@ -88,7 +89,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
||||
<Player
|
||||
topics={topics?.topics || []}
|
||||
useActiveTopic={useActiveTopic}
|
||||
waveform={waveform.waveform.data}
|
||||
waveform={waveform.waveform}
|
||||
media={mp3.media}
|
||||
mediaDuration={transcript.response.duration}
|
||||
/>
|
||||
@@ -108,10 +109,10 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
||||
|
||||
<div className="w-full h-full grid grid-rows-layout-one grid-cols-1 gap-2 lg:gap-4">
|
||||
<section className=" bg-blue-400/20 rounded-lg md:rounded-xl p-2 md:px-4 h-full">
|
||||
{transcript.response.longSummary ? (
|
||||
{transcript.response.long_summary ? (
|
||||
<FinalSummary
|
||||
fullTranscript={fullTranscript}
|
||||
summary={transcript.response.longSummary}
|
||||
summary={transcript.response.long_summary}
|
||||
transcriptId={transcript.response.id}
|
||||
openZulipModal={() => setShowModal(true)}
|
||||
/>
|
||||
@@ -139,9 +140,9 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
||||
</div>
|
||||
<div className="flex-grow max-w-full">
|
||||
<ShareLink
|
||||
transcriptId={transcript?.response?.id}
|
||||
userId={transcript?.response?.userId}
|
||||
shareMode={transcript?.response?.shareMode}
|
||||
transcriptId={transcript.response.id}
|
||||
userId={transcript.response.user_id}
|
||||
shareMode={toShareMode(transcript.response.share_mode)}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -62,8 +62,9 @@ const TranscriptRecord = (details: TranscriptDetails) => {
|
||||
|
||||
//TODO if has no topic and is error, get back to new
|
||||
if (
|
||||
statusToRedirect.includes(transcript.response?.status) ||
|
||||
statusToRedirect.includes(webSockets.status.value)
|
||||
transcript.response?.status &&
|
||||
(statusToRedirect.includes(transcript.response?.status) ||
|
||||
statusToRedirect.includes(webSockets.status.value))
|
||||
) {
|
||||
const newUrl = "/transcripts/" + details.params.transcriptId;
|
||||
// Shallow redirection does not work on NextJS 13
|
||||
@@ -75,10 +76,8 @@ const TranscriptRecord = (details: TranscriptDetails) => {
|
||||
}, [webSockets.status.value, transcript.response?.status]);
|
||||
|
||||
useEffect(() => {
|
||||
if (webSockets.duration) {
|
||||
mp3.getNow();
|
||||
}
|
||||
}, [webSockets.duration]);
|
||||
if (transcript.response?.status === "ended") mp3.getNow();
|
||||
}, [transcript.response]);
|
||||
|
||||
useEffect(() => {
|
||||
lockWakeState();
|
||||
@@ -112,6 +111,7 @@ const TranscriptRecord = (details: TranscriptDetails) => {
|
||||
}}
|
||||
getAudioStream={getAudioStream}
|
||||
audioDevices={audioDevices}
|
||||
transcriptId={details.params.transcriptId}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user