import React, { useRef } from 'react' import type { FC } from 'react' import { useTranslation } from 'react-i18next' import { ChatBubbleOvalLeftEllipsisIcon, PencilSquareIcon, } from '@heroicons/react/24/outline' import { ChatBubbleOvalLeftEllipsisIcon as ChatBubbleOvalLeftEllipsisSolidIcon } from '@heroicons/react/24/solid' import { useInfiniteScroll } from 'ahooks' import Button from '../../../base/button' import AppInfo from '@/app/components/share/chat/sidebar/app-info' // import Card from './card' import type { ConversationItem, SiteInfo } from '@/models/share' import { fetchConversations } from '@/service/share' function classNames(...classes: any[]) { return classes.filter(Boolean).join(' ') } export type ISidebarProps = { copyRight: string currentId: string onCurrentIdChange: (id: string) => void list: ConversationItem[] isInstalledApp: boolean installedAppId?: string siteInfo: SiteInfo onMoreLoaded: (res: { data: ConversationItem[]; has_more: boolean }) => void isNoMore: boolean } const Sidebar: FC = ({ copyRight, currentId, onCurrentIdChange, list, isInstalledApp, installedAppId, siteInfo, onMoreLoaded, isNoMore, }) => { const { t } = useTranslation() const listRef = useRef(null) useInfiniteScroll( async () => { if (!isNoMore) { const lastId = list[list.length - 1].id const { data: conversations, has_more }: any = await fetchConversations(isInstalledApp, installedAppId, lastId) onMoreLoaded({ data: conversations, has_more }) } return { list: [] } }, { target: listRef, isNoMore: () => { return isNoMore }, reloadDeps: [isNoMore], }, ) return (
{isInstalledApp && ( )}
© {copyRight} {(new Date()).getFullYear()}
) } export default React.memo(Sidebar)