fix(news): auto-retry news fetch when backend Celery task is in-flight
When a bill page opens with no stored articles, the backend queues a fetch_news_for_bill Celery task and returns immediately. Added a retry loop (up to 3x, 6 s apart) driven off newsArticles state so articles populate without a manual refresh. Fixed broken useEffect dependency ([billId] → [newsArticles]) that caused the timer to never fire. News is now fetched via a separate useBillNews query (staleTime: 0) independent of the cached bill detail response. Co-Authored-By: Jack Levy
This commit is contained in:
@@ -31,7 +31,7 @@ export function useBillNews(id: string) {
|
||||
return useQuery({
|
||||
queryKey: ["bill-news", id],
|
||||
queryFn: () => billsAPI.getNews(id),
|
||||
staleTime: 10 * 60 * 1000,
|
||||
staleTime: 0, // Always fetch fresh — news arrives async after brief generation
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user