Improve video recommendations by fetching related videos

Update client-side logic to fetch and display recommended videos, excluding the currently playing video.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/nme9hcD
This commit is contained in:
sebastjanartic 2025-08-28 11:43:33 +00:00
parent 1ede557133
commit 21b8f43c9b

View File

@ -54,16 +54,23 @@ export default function VideoPage() {
// Fetch current video
const { data: currentVideo, isLoading: videoLoading } = useQuery<Video>({
queryKey: [`/api/videos/${videoId}`],
queryFn: () => fetch(`/api/videos/${videoId}`).then(res => res.json()),
enabled: !!videoId,
});
// Fetch recommended videos (excluding current video)
const { data: recommendedResponse } = useQuery<VideosResponse>({
queryKey: ["/api/videos", { limit: 20, offset: 0 }],
queryKey: ["/api/videos"],
queryFn: () => fetch("/api/videos?limit=20&offset=0").then(res => res.json()),
enabled: !!videoId,
});
const recommendedVideos = recommendedResponse?.videos?.filter(v => v.id !== videoId) || [];
// Debug log
console.log('Current video ID:', videoId);
console.log('Recommended response:', recommendedResponse);
console.log('Filtered recommended videos:', recommendedVideos);
// Track video view
const handleVideoPlay = async () => {