fixed auto update of filtered queries for jobs list

This commit is contained in:
michael 2025-10-16 11:59:17 -05:00
parent 762d7bcb38
commit df09f30d63

View file

@ -200,42 +200,20 @@ export function useJobStatusWebSocket(
return; // Don't update status cache for asset events
}
// Update individual job cache if we have job_id
// For status updates, invalidate ALL job queries to ensure filtered lists refresh
if (update.job_id) {
queryClient.setQueryData(['jobs', update.job_id], (oldData: unknown) => {
if (oldData) {
return {
...oldData,
status: update.status,
updated_at: update.updated_at
};
}
return oldData;
// Invalidate specific job
queryClient.invalidateQueries({
queryKey: ['jobs', update.job_id]
});
// Invalidate ALL job list queries (including filtered ones like QC, Final Review)
// This ensures QCList and FinalList refresh when jobs change status
queryClient.invalidateQueries({
queryKey: ['jobs'],
exact: false // Match all queries starting with ['jobs']
});
}
// Update job list cache
queryClient.setQueriesData({ queryKey: ['jobs'] }, (oldData: unknown) => {
// Type-safe handling of the jobs list data
const data = oldData as { jobs?: Array<{ id: string; status: string; updated_at: string; [key: string]: unknown }> };
if (!data?.jobs) return oldData;
const updatedJobs = data.jobs.map((job) => {
if (job.id === update.job_id) {
return {
...job,
status: update.status,
updated_at: update.updated_at
};
}
return job;
});
return {
...data,
jobs: updatedJobs
};
});
}, [queryClient]);
const handleMessage = useCallback((event: MessageEvent) => {