"use client" import { useEffect, useState, useTransition } from "react" import { useStore } from "@/app/state/useStore" import { cn } from "@/lib/utils/cn" import { VideoList } from "@/components/interface/video-list" import { DefaultAvatar } from "@/components/interface/default-avatar" export function PublicChannelView() { const [_isPending, startTransition] = useTransition() const publicChannel = useStore(s => s.publicChannel) const publicChannelVideos = useStore(s => s.publicChannelVideos) const setPublicChannelVideos = useStore(s => s.setPublicChannelVideos) const [channelThumbnail, setChannelThumbnail] = useState(publicChannel?.thumbnail || "") const handleBadChannelThumbnail = () => { try { if (channelThumbnail) { setChannelThumbnail("") } } catch (err) { } } useEffect(() => { setChannelThumbnail(publicChannel?.thumbnail || "") if (!publicChannel) { return } // we already have all the videos we need (eg. they were rendered server-side) // if (publicChannelVideos.length) { return } // setPublicChannelVideos([]) // do we really need this? normally this was computed server-side /* startTransition(async () => { const newPublicChannelVideos = await getChannelVideos({ channel: publicChannel, status: "published", }) console.log("publicChannelVideos:", newPublicChannelVideos) setPublicChannelVideos(newPublicChannelVideos) }) */ }, [publicChannel, publicChannel?.id]) if (!publicChannel) { return null } return (
{/* BANNER */}
{channelThumbnail ? : }
{/* CHANNEL INFO - HORIZONTAL */}
{/* AVATAR */}
{channelThumbnail ? : }

{publicChannel.label}

) }