'use client'; import ChatCard, { ChatCardLayout } from './ChatCard'; import { IconPlus } from '../ui/Icons'; import { auth } from '@/auth'; import { ChatEntity } from '@/lib/types'; import { VariableSizeList as List } from 'react-window'; import { cleanInputMessage } from '@/lib/messageUtils'; import AutoSizer from 'react-virtualized-auto-sizer'; export interface ChatSidebarListProps { chats: ChatEntity[]; isAdminView?: boolean; } const getItemSize = (message: string, isAdminView?: boolean) => { if (message.length >= 45) return 116; else if (message.length >= 20) return 104; else return 88; }; export default async function ChatSidebarList({ chats, isAdminView, }: ChatSidebarListProps) { return ( <> {!isAdminView && (

New chat

)} {({ height, width }) => ( getItemSize( cleanInputMessage(chats[index].messages?.[0]?.content ?? ''), isAdminView, ) } width={width} > {({ style, index, data }) => (
)}
)}
); }