diff --git a/frontend/src/app/notebooks/[id]/page.tsx b/frontend/src/app/notebooks/[id]/page.tsx index 7a5d683..3ccae34 100644 --- a/frontend/src/app/notebooks/[id]/page.tsx +++ b/frontend/src/app/notebooks/[id]/page.tsx @@ -3,6 +3,7 @@ import { useState, useRef, useEffect, useCallback, useMemo } from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { notebookAPI, documentAPI, authAPI } from '@/lib/api'; +import type { PodcastStatus } from '@/types'; import { useParams } from 'next/navigation'; import Link from 'next/link'; import { @@ -88,14 +89,13 @@ export default function NotebookDetailPage() { refetchInterval: hasProcessingTasks ? 2000 : false, }); - const { data: podcastStatus } = useQuery({ + const { data: podcastStatus } = useQuery({ queryKey: ['podcast-status', notebookId], queryFn: async () => { const response = await notebookAPI.getPodcastStatus(notebookId); return response.data; }, - // Poll only while a podcast is actively generating; initial load via refetchOnMount - refetchInterval: podcastStatus?.status === 'processing' ? 5000 : false, + refetchInterval: (query) => query.state.data?.status === 'processing' ? 5000 : false, }); const { data: shares } = useQuery({