fix: skip downloads fetch for jobs still in early processing stages
useJobDownloads now accepts jobStatus and disables the query when the
job is in created/ingesting/ai_processing, preventing spurious 400s
from /jobs/{id}/downloads before any outputs exist.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
222826baa7
commit
d2d393c5c7
5 changed files with 8 additions and 6 deletions
|
|
@ -32,11 +32,13 @@ export function useJob(jobId: string) {
|
|||
});
|
||||
}
|
||||
|
||||
export function useJobDownloads(jobId: string) {
|
||||
const EARLY_STATUSES = new Set(['created', 'ingesting', 'ai_processing']);
|
||||
|
||||
export function useJobDownloads(jobId: string, jobStatus?: string) {
|
||||
return useQuery({
|
||||
queryKey: ['jobs', jobId, 'downloads'],
|
||||
queryFn: () => apiClient.getJobDownloads(jobId),
|
||||
enabled: !!jobId,
|
||||
enabled: !!jobId && (jobStatus === undefined || !EARLY_STATUSES.has(jobStatus)),
|
||||
staleTime: 30000, // 30 seconds
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ export function Downloads() {
|
|||
const { id } = useParams();
|
||||
|
||||
const { data: job, isLoading: jobLoading } = useJob(id!);
|
||||
const { data: downloads, isLoading: downloadsLoading, error: downloadsError } = useJobDownloads(id!);
|
||||
const { data: downloads, isLoading: downloadsLoading, error: downloadsError } = useJobDownloads(id!, job?.status);
|
||||
|
||||
if (jobLoading) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export function FinalDetail() {
|
|||
|
||||
const { data: job, isLoading, error } = useJob(id!);
|
||||
const { data: validation } = useJobValidation(id!);
|
||||
const { data: downloads } = useJobDownloads(id!);
|
||||
const { data: downloads } = useJobDownloads(id!, job?.status);
|
||||
const completeJobMutation = useCompleteJob();
|
||||
const rejectFinalMutation = useRejectFinalReview();
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export function QCDetail() {
|
|||
|
||||
// Fetch VTT content for selected language
|
||||
const { data: vttContent, isLoading: vttLoading } = useJobVttContent(id!, selectedLanguage);
|
||||
const { data: downloads } = useJobDownloads(id!);
|
||||
const { data: downloads } = useJobDownloads(id!, job?.status);
|
||||
|
||||
// Fetch accessible video edit state for selected language
|
||||
const { data: editState, isLoading: editStateLoading } = useAccessibleVideoEditState(id!, selectedLanguage);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ export function JobDetail() {
|
|||
const [activeTab, setActiveTab] = useState<'overview' | 'video' | 'assets' | 'history'>('overview');
|
||||
|
||||
const { data: job, isLoading, error } = useJob(id!);
|
||||
const { data: downloads } = useJobDownloads(id!);
|
||||
const { data: downloads } = useJobDownloads(id!, job?.status);
|
||||
// Get source language from job (default to 'en' for backwards compatibility)
|
||||
const sourceLanguage = job?.source?.language || 'en';
|
||||
const { data: sourceVtt } = useJobVttContent(id!, sourceLanguage);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue