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:
Jack Levy
2026-03-01 03:17:17 -05:00
parent d5711312b8
commit 12a3eac48f
2 changed files with 21 additions and 4 deletions

View File

@@ -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,
});
}