Spaces:
Running
Running
File size: 1,347 Bytes
f27679f 1f122c3 f42b4a1 ac7030c 3d4392e f42b4a1 1f122c3 f27679f 851546d 3d4392e 1f122c3 f27679f 3d4392e f27679f 4c34e70 3d4392e f27679f 1f122c3 b161bd3 3d4392e b161bd3 3d4392e f27679f 851546d 1f122c3 3d4392e f42b4a1 3d4392e f27679f 1f122c3 2ed75c8 1f122c3 f27679f 3d4392e 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 |
"use client"
import { useEffect, useTransition } from "react"
import { useStore } from "@/app/state/useStore"
import { cn } from "@/lib/utils/cn"
import { MediaInfo } from "@/types/general"
import { getVideos } from "@/app/api/actions/ai-tube-hf/getVideos"
import { VideoList } from "@/components/interface/video-list"
export function HomeView() {
const [_isPending, startTransition] = useTransition()
const setView = useStore(s => s.setView)
const currentTag = useStore(s => s.currentTag)
const setPublicMedias = useStore(s => s.setPublicMedias)
const setPublicMedia = useStore(s => s.setPublicMedia)
const publicMedias = useStore(s => s.publicMedias)
useEffect(() => {
startTransition(async () => {
const medias = await getVideos({
sortBy: "date",
mandatoryTags: currentTag ? [currentTag] : [],
maxNbMedias: 25
})
// due to some caching on the first function.. we update with fresh data!
// const updatedVideos = await extendVideosWithStats(medias)
setPublicMedias(medias)
})
}, [currentTag])
const handleSelect = (media: MediaInfo) => {
setView("public_media")
setPublicMedia(media)
}
return (
<div className={cn(
`sm:pr-4`
)}>
<VideoList
items={publicMedias}
onSelect={handleSelect}
/>
</div>
)
} |