Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,095 Bytes
f27679f a64395a 1f122c3 851546d a64395a 1f122c3 f62b8d3 a64395a 1f122c3 a3f1817 a64395a 1f122c3 a64395a a3f1817 a64395a a3f1817 a64395a 1f122c3 a64395a 1f122c3 f27679f a64395a 93f8352 a3f1817 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 |
"use client"
import { useEffect, useState, useTransition } from "react"
import { useStore } from "@/app/state/useStore"
import { cn } from "@/lib/utils"
import { getChannels } from "@/app/server/actions/ai-tube-hf/getChannels"
import { ChannelList } from "@/app/interface/channel-list"
export function PublicChannelsView() {
const [_isPending, startTransition] = useTransition()
const publicChannels = useStore(s => s.publicChannels)
const setPublicChannels = useStore(s => s.setPublicChannels)
const [isLoaded, setLoaded] = useState(false)
useEffect(() => {
if (!isLoaded) {
startTransition(async () => {
try {
const channels = await getChannels()
setPublicChannels(channels)
} catch (err) {
console.error("failed to load the public channels", err)
setPublicChannels([])
} finally {
setLoaded(true)
}
})
}
}, [isLoaded])
return (
<div className={cn(`flex flex-col`)}>
<ChannelList
layout="grid"
channels={publicChannels}
/>
</div>
)
} |