"use client" import { useEffect, useState, useTransition } from "react" import { useStore } from "@/app/state/useStore" import { cn } from "@/lib/utils/cn" import { ChannelList } from "@/components/interface/channel-list" import { getPrivateChannels } from "@/app/api/actions/ai-tube-hf/getPrivateChannels" import { useCurrentUser } from "@/app/state/useCurrentUser" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" export function UserAccountView() { const [_isPending, startTransition] = useTransition() const { user, login, apiKey, longStandingApiKey, setLongStandingApiKey } = useCurrentUser({ isLoginRequired: true }) const setView = useStore(s => s.setView) const userChannel = useStore(s => s.userChannel) const setUserChannel = useStore(s => s.setUserChannel) const userChannels = useStore(s => s.userChannels) const setUserChannels = useStore(s => s.setUserChannels) const [isLoaded, setLoaded] = useState(false) useEffect(() => { startTransition(async () => { if (!isLoaded && apiKey) { try { const newUserChannels = await getPrivateChannels({ apiKey, renewCache: true, }) setUserChannels(newUserChannels) } catch (err) { console.error("failed to load the channel for the current user:", err) setUserChannels([]) } finally { setLoaded(true) } } }) }, [isLoaded, apiKey, userChannels.map(c => c.id).join(","), setUserChannels, setLoaded]) const showSecretFeature = user?.userName.startsWith("jbilcke") return (
Don't see your channel? try to again.
: null } {userChannels?.length ?Loading channels owned by @{user?.userName}..
}To create a channel, comment or like a video please .
: null) }