Spaces:
Running
Running
File size: 1,498 Bytes
f27679f 1f122c3 ac7030c f27679f df83860 b161bd3 1f122c3 f27679f 851546d a3f1817 1f122c3 f27679f 4c34e70 f27679f 1f122c3 b161bd3 a3f1817 f27679f 851546d 1f122c3 ac7030c f27679f a3f1817 f27679f 1f122c3 2ed75c8 1f122c3 f27679f 8f2b05f f27679f 1f122c3 |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
"use client"
import { useEffect, useTransition } from "react"
import { useStore } from "@/app/state/useStore"
import { cn } from "@/lib/utils"
import { MediaInfo } from "@/types/general"
import { getVideos } from "@/app/server/actions/ai-tube-hf/getVideos"
import { VideoList } from "@/app/interface/video-list"
import { getTags } from "@/app/server/actions/ai-tube-hf/getTags"
import { extendVideosWithStats } from "@/app/server/actions/ai-tube-hf/extendVideosWithStats"
export function HomeView() {
const [_isPending, startTransition] = useTransition()
const setView = useStore(s => s.setView)
const currentTag = useStore(s => s.currentTag)
const setPublicVideos = useStore(s => s.setPublicVideos)
const setPublicVideo = useStore(s => s.setPublicVideo)
const publicVideos = useStore(s => s.publicVideos)
useEffect(() => {
startTransition(async () => {
const videos = await getVideos({
sortBy: "date",
mandatoryTags: currentTag ? [currentTag] : [],
maxVideos: 25
})
// due to some caching on the first function.. we update with fresh data!
// const updatedVideos = await extendVideosWithStats(videos)
setPublicVideos(videos)
})
}, [currentTag])
const handleSelect = (video: MediaInfo) => {
setView("public_video")
setPublicVideo(video)
}
return (
<div className={cn(
`sm:pr-4`
)}>
<VideoList
items={publicVideos}
onSelect={handleSelect}
/>
</div>
)
} |