File size: 914 Bytes
4c34e70
 
 
 
ac7030c
4c34e70
 
3d4392e
4c34e70
 
ac7030c
4c34e70
ac7030c
 
4c34e70
 
 
 
 
 
 
 
 
ac7030c
 
3d4392e
4c34e70
 
ac7030c
4c34e70
 
 
8f2b05f
4c34e70
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

import { useEffect, useTransition } from "react"

import { useStore } from "@/app/state/useStore"
import { MediaInfo } from "@/types/general"

import { VideoList } from "../video-list"
import { getVideos } from "@/app/api/actions/ai-tube-hf/getVideos"

export function RecommendedVideos({
  media,
}: {
  // the media to use for the recommendations
  media: MediaInfo
}) {
  const [_isPending, startTransition] = useTransition()
  const setRecommendedVideos = useStore(s => s.setRecommendedVideos)
  const recommendedVideos = useStore(s => s.recommendedVideos)

  useEffect(() => {
    startTransition(async () => {
      setRecommendedVideos(await getVideos({
        sortBy: "random",
        niceToHaveTags: media.tags,
        ignoreVideoIds: [media.id],
        maxNbMedias: 16,
      }))
    })
  }, media.tags)

  return (
    <VideoList
      items={recommendedVideos}
      layout="vertical"
    />
  )
}