'use client' import * as React from 'react' import Link from 'next/link' import { usePathname } from 'next/navigation' import { motion } from 'framer-motion' import { buttonVariants } from '@/components/ui/button' import { IconMessage, IconUsers } from '@/components/ui/icons' import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip' import { useLocalStorage } from '@/lib/hooks/use-local-storage' import { type Chat } from '@/lib/types' import { cn } from '@/lib/utils' interface SidebarItemProps { index: number chat: Chat children: React.ReactNode } export function SidebarItem({ index, chat, children }: SidebarItemProps) { const pathname = usePathname() const isActive = pathname === chat.path const [newChatId, setNewChatId] = useLocalStorage('newChatId', null) const shouldAnimate = index === 0 && isActive && newChatId if (!chat?.id) return null return (
{chat.sharePath ? ( This is a shared chat. ) : ( )}
{shouldAnimate ? ( chat.title.split('').map((character, index) => ( { if (index === chat.title.length - 1) { setNewChatId(null) } }} > {character} )) ) : ( {chat.title} )}
{isActive &&
{children}
}
) }