diff --git a/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx b/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx index 6501ca684..7b14c7ed1 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/chats/chats-client.tsx @@ -472,11 +472,12 @@ export default function ChatsPageClient({ searchSpaceId }: ChatsPageClientProps) size="sm" onClick={selectAllVisibleChats} className="gap-1" + title="Select or deselect all chats on the current page" > {currentChats.every(chat => selectedChats.includes(chat.id)) - ? "Deselect All" - : "Select All"} + ? "Deselect Page" + : "Select Page"} diff --git a/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx b/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx index cacee7061..72e50ab95 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/podcasts/podcasts-client.tsx @@ -38,7 +38,7 @@ import { } from "@/components/ui/select"; import { toast } from "sonner"; -interface Podcast { +interface PodcastItem { id: number; title: string; created_at: string; @@ -66,8 +66,8 @@ const podcastCardVariants = { const MotionCard = motion(Card); export default function PodcastsPageClient({ searchSpaceId }: PodcastsPageClientProps) { - const [podcasts, setPodcasts] = useState([]); - const [filteredPodcasts, setFilteredPodcasts] = useState([]); + const [podcasts, setPodcasts] = useState([]); + const [filteredPodcasts, setFilteredPodcasts] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); const [searchQuery, setSearchQuery] = useState(''); @@ -77,7 +77,7 @@ export default function PodcastsPageClient({ searchSpaceId }: PodcastsPageClient const [isDeleting, setIsDeleting] = useState(false); // Audio player state - const [currentPodcast, setCurrentPodcast] = useState(null); + const [currentPodcast, setCurrentPodcast] = useState(null); const [audioSrc, setAudioSrc] = useState(undefined); const [isAudioLoading, setIsAudioLoading] = useState(false); const [isPlaying, setIsPlaying] = useState(false); @@ -123,7 +123,7 @@ export default function PodcastsPageClient({ searchSpaceId }: PodcastsPageClient throw new Error(`Failed to fetch podcasts: ${response.status} ${errorData?.detail || ''}`); } - const data: Podcast[] = await response.json(); + const data: PodcastItem[] = await response.json(); setPodcasts(data); setFilteredPodcasts(data); setError(null); @@ -257,7 +257,7 @@ export default function PodcastsPageClient({ searchSpaceId }: PodcastsPageClient }; // Play podcast - Fetch blob and set object URL - const playPodcast = async (podcast: Podcast) => { + const playPodcast = async (podcast: PodcastItem) => { // If the same podcast is selected, just toggle play/pause if (currentPodcast && currentPodcast.id === podcast.id) { togglePlayPause(); @@ -302,12 +302,14 @@ export default function PodcastsPageClient({ searchSpaceId }: PodcastsPageClient const blob = await response.blob(); const objectUrl = URL.createObjectURL(blob); currentObjectUrlRef.current = objectUrl; + + // Wait for React to commit the new `src` setAudioSrc(objectUrl); - // Let the audio element load the new src - setTimeout(() => { + // Use requestAnimationFrame instead of setTimeout for more reliable DOM updates + requestAnimationFrame(() => { if (audioRef.current) { - audioRef.current.load(); + // The