fix: poll for rendering_qc status and refresh timeline preview on completion
Fixes race condition where timeline preview never updated after AD VTT re-render: useJob now polls every 5s during rendering_qc, and QCDetail invalidates the edit-state query when the job transitions back to pending_qc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
76ca74d5a5
commit
539e11caca
2 changed files with 20 additions and 0 deletions
|
|
@ -29,6 +29,10 @@ export function useJob(jobId: string) {
|
|||
enabled: !!jobId,
|
||||
staleTime: 30000, // 30 seconds
|
||||
refetchOnWindowFocus: false,
|
||||
refetchInterval: (query) => {
|
||||
const status = query.state.data?.status;
|
||||
return status === 'rendering_qc' ? 5000 : false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useState, useEffect, useRef, useMemo } from 'react';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { useJob, useApproveEnglish, useRejectJob, useJobVttContent, useUpdateJobVtt, useJobDownloads, useAdjustVttTiming, useUpdateTTSPreferences } from '../../hooks/useJob';
|
||||
import {
|
||||
|
|
@ -88,6 +89,7 @@ export function QCDetail() {
|
|||
const [adVttUploaded, setAdVttUploaded] = useState(false);
|
||||
const captionsFileInputRef = useRef<HTMLInputElement>(null);
|
||||
const adFileInputRef = useRef<HTMLInputElement>(null);
|
||||
const prevJobStatusRef = useRef<string | undefined>(undefined);
|
||||
const [ttsPreferences, setTtsPreferences] = useState<TTSPreferences>({
|
||||
provider: 'gemini',
|
||||
default_voice: 'Kore',
|
||||
|
|
@ -119,6 +121,20 @@ export function QCDetail() {
|
|||
setLastDeletedAdCue(null);
|
||||
}, [selectedLanguage]);
|
||||
|
||||
// Refresh edit state when render completes (rendering_qc → pending_qc transition)
|
||||
const queryClient = useQueryClient();
|
||||
useEffect(() => {
|
||||
if (
|
||||
prevJobStatusRef.current === 'rendering_qc' &&
|
||||
job?.status === 'pending_qc'
|
||||
) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['jobs', id, 'accessible-video', selectedLanguage, 'edit-state'],
|
||||
});
|
||||
}
|
||||
prevJobStatusRef.current = job?.status;
|
||||
}, [job?.status, id, selectedLanguage, queryClient]);
|
||||
|
||||
// Sync pending regenerations from server edit state
|
||||
useEffect(() => {
|
||||
if (editState?.tts_regeneration_queue) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue