feat: add on preview complete

This commit is contained in:
Rohit
2025-06-25 12:57:15 +05:30
parent d5f54408b5
commit 9512433adc

View File

@@ -10,6 +10,7 @@ import { useTranslation } from "react-i18next";
interface InterpretationButtonsProps { interface InterpretationButtonsProps {
enableStepping: (isPaused: boolean) => void; enableStepping: (isPaused: boolean) => void;
onPreviewComplete?: () => void;
} }
interface InterpretationInfo { interface InterpretationInfo {
@@ -22,7 +23,7 @@ const interpretationInfo: InterpretationInfo = {
isPaused: false, isPaused: false,
}; };
export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsProps) => { export const InterpretationButtons = ({ enableStepping, onPreviewComplete }: InterpretationButtonsProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [info, setInfo] = useState<InterpretationInfo>(interpretationInfo); const [info, setInfo] = useState<InterpretationInfo>(interpretationInfo);
const [decisionModal, setDecisionModal] = useState<{ const [decisionModal, setDecisionModal] = useState<{
@@ -102,16 +103,20 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
}, [socket, finishedHandler, breakpointHitHandler]); }, [socket, finishedHandler, breakpointHitHandler]);
const handlePlay = async () => { const handlePlay = async () => {
if (!info.running) { onPreviewComplete?.();
setInfo({ ...info, running: true }); notify('info', t('interpretation_buttons.messages.run_finished'));
const finished = await interpretCurrentRecording();
setInfo({ ...info, running: false }); // Legacy code for running the interpretation
if (finished) {
notify('info', t('interpretation_buttons.messages.run_finished')); // if (!info.running) {
} else { // setInfo({ ...info, running: true });
notify('error', t('interpretation_buttons.messages.run_failed')); // // const finished = await interpretCurrentRecording();
} // setInfo({ ...info, running: false });
} // if (finished) {
// } else {
// notify('error', t('interpretation_buttons.messages.run_failed'));
// }
// }
}; };
// pause and stop logic (do not delete - we wil bring this back!) // pause and stop logic (do not delete - we wil bring this back!)