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:
parent
1ede557133
commit
21b8f43c9b
@ -54,17 +54,24 @@ export default function VideoPage() {
|
|||||||
// Fetch current video
|
// Fetch current video
|
||||||
const { data: currentVideo, isLoading: videoLoading } = useQuery<Video>({
|
const { data: currentVideo, isLoading: videoLoading } = useQuery<Video>({
|
||||||
queryKey: [`/api/videos/${videoId}`],
|
queryKey: [`/api/videos/${videoId}`],
|
||||||
|
queryFn: () => fetch(`/api/videos/${videoId}`).then(res => res.json()),
|
||||||
enabled: !!videoId,
|
enabled: !!videoId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch recommended videos (excluding current video)
|
// Fetch recommended videos (excluding current video)
|
||||||
const { data: recommendedResponse } = useQuery<VideosResponse>({
|
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,
|
enabled: !!videoId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const recommendedVideos = recommendedResponse?.videos?.filter(v => v.id !== 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
|
// Track video view
|
||||||
const handleVideoPlay = async () => {
|
const handleVideoPlay = async () => {
|
||||||
if (currentVideo) {
|
if (currentVideo) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user