diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx index 839a5807..04cddb32 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/page.tsx @@ -38,7 +38,6 @@ export function selectedTextIsTimeSlice( export default function TranscriptCorrect(details: TranscriptCorrect) { const transcriptId = details.params.transcriptId; - const transcript = useTranscript(transcriptId); const stateCurrentTopic = useState(); const [currentTopic, _sct] = stateCurrentTopic; const topicWithWords = useTopicWithWords(currentTopic?.id, transcriptId); @@ -47,7 +46,6 @@ export default function TranscriptCorrect(details: TranscriptCorrect) { const participants = useParticipants(transcriptId); const stateSelectedText = useState(); const [selectedText, _sst] = stateSelectedText; - console.log(selectedText); useEffect(() => { if (currentTopic) { @@ -60,9 +58,6 @@ export default function TranscriptCorrect(details: TranscriptCorrect) { } }, [currentTopic]); - // TODO BE - // Creating a participant and a speaker ? - return (
diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/participantList.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/participantList.tsx index 4a6a10f7..b187b400 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/participantList.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/participantList.tsx @@ -12,7 +12,7 @@ type ParticipantList = { topicWithWords: any; stateSelectedText: any; }; - +// NTH re-order list when searching const ParticipantList = ({ transcriptId, participants, @@ -31,12 +31,6 @@ const ParticipantList = ({ >(null); const [oneMatch, setOneMatch] = useState(); - useEffect(() => { - if (loading) { - setLoading(false); - } - }, [participants.loading]); - useEffect(() => { if (participants.response) { if (selectedTextIsSpeaker(selectedText)) { @@ -93,6 +87,7 @@ const ParticipantList = ({ useEffect(() => { document.onkeyup = (e) => { + if (loading || participants.loading || topicWithWords.loading) return; if (e.key === "Enter" && e.ctrlKey) { if (oneMatch) { if (action == "Create and assign") { @@ -115,7 +110,9 @@ const ParticipantList = ({ const mergeSpeaker = (speakerFrom, participantTo: Participant) => async () => { + if (loading || participants.loading || topicWithWords.loading) return; if (participantTo.speaker) { + setLoading(true); await api?.v1TranscriptMergeSpeaker({ transcriptId, speakerMerge: { @@ -134,17 +131,25 @@ const ParticipantList = ({ topicWithWords.refetch(); setAction(null); setParticipantInput(""); + setLoading(false); }; const doAction = (e?) => { e?.preventDefault(); e?.stopPropagation(); - if (!participants.response) return; + if ( + loading || + participants.loading || + topicWithWords.loading || + !participants.response + ) + return; if (action == "Rename" && selectedTextIsSpeaker(selectedText)) { const participant = participants.response.find( (p) => p.speaker == selectedText, ); if (participant && participant.name !== participantInput) { + setLoading(true); api ?.v1TranscriptUpdateParticipant({ participantId: participant.id, @@ -155,6 +160,7 @@ const ParticipantList = ({ }) .then(() => { participants.refetch(); + setLoading(false); }); } } else if ( @@ -173,6 +179,7 @@ const ParticipantList = ({ .then(() => { participants.refetch(); setParticipantInput(""); + setLoading(false); }); } else if ( action == "Create and assign" && @@ -187,8 +194,8 @@ const ParticipantList = ({ transcriptId, }) .then((participant) => { + setLoading(false); assignTo(participant)(); - participants.refetch(); setParticipantInput(""); }); } else if (action == "Create") { @@ -203,31 +210,34 @@ const ParticipantList = ({ .then(() => { participants.refetch(); setParticipantInput(""); + setLoading(false); }); } }; const deleteParticipant = (participantId) => (e) => { e.stopPropagation(); - if (!loading) { - api - ?.v1TranscriptDeleteParticipant({ - transcriptId, - participantId, - }) - .then(() => { - participants.refetch(); - }); - } + if (loading || participants.loading || topicWithWords.loading) return; + setLoading(true); + api + ?.v1TranscriptDeleteParticipant({ + transcriptId, + participantId, + }) + .then(() => { + participants.refetch(); + setLoading(false); + }); }; const assignTo = (participant) => (e?: React.MouseEvent) => { e?.preventDefault(); e?.stopPropagation(); - // fix participant that doesnt have a speaker (wait API) + if (loading || participants.loading || topicWithWords.loading) return; if (!selectedTextIsTimeSlice(selectedText)) return; + setLoading(true); api ?.v1TranscriptAssignSpeaker({ speakerAssignment: { @@ -239,6 +249,8 @@ const ParticipantList = ({ }) .then(() => { topicWithWords.refetch(); + participants.refetch(); + setLoading(false); }); }; @@ -253,6 +265,7 @@ const ParticipantList = ({ setSelectedParticipant(undefined); setSelectedText(undefined); setAction(null); + setParticipantInput(""); }; const preventClick = (e) => { e?.stopPropagation(); @@ -279,12 +292,14 @@ const ParticipantList = ({ )}
- {participants.loading && ( - - )} + {loading || + participants.loading || + (topicWithWords.loading && ( + + ))} {participants.response && (
    {participants.response.map((participant: Participant) => ( @@ -306,23 +321,25 @@ const ParticipantList = ({ {participant.name}
    - {selectedTextIsSpeaker(selectedText) && !loading && ( - - )} + {selectedTextIsSpeaker(selectedText) && + !selectedParticipant && + !loading && ( + + )} {selectedTextIsTimeSlice(selectedText) && !loading && (