"use client" import { useEffect, useState, useTransition } from "react" import { useStore } from "@/app/state/useStore" import { cn } from "@/lib/utils" import { VideoList } from "@/app/interface/video-list" import { getChannelVideos } from "@/app/server/actions/ai-tube-hf/getChannelVideos" import { DefaultAvatar } from "@/app/interface/default-avatar" export function PublicChannelView() { const [_isPending, startTransition] = useTransition() const publicChannel = useStore(s => s.publicChannel) const publicVideos = useStore(s => s.publicVideos) const setPublicVideos = useStore(s => s.setPublicVideos) const [channelThumbnail, setChannelThumbnail] = useState(publicChannel?.thumbnail || "") const handleBadChannelThumbnail = () => { try { if (channelThumbnail) { setChannelThumbnail("") } } catch (err) { } } useEffect(() => { setChannelThumbnail(publicChannel?.thumbnail || "") if (!publicChannel) { return } startTransition(async () => { const videos = await getChannelVideos({ channel: publicChannel, status: "published", }) console.log("videos:", videos) setPublicVideos(videos) }) setPublicVideos([]) }, [publicChannel, publicChannel?.id]) if (!publicChannel) { return null } return (
{/* BANNER */}
{channelThumbnail ? : }
{/* CHANNEL INFO - HORIZONTAL */}
{/* AVATAR */}
{channelThumbnail ? : }

{publicChannel.label}

) }