'use client' import type { FC } from 'react' import React, { useRef } from 'react' import { ChatBubbleOvalLeftEllipsisIcon, } from '@heroicons/react/24/outline' import { useInfiniteScroll } from 'ahooks' import { ChatBubbleOvalLeftEllipsisIcon as ChatBubbleOvalLeftEllipsisSolidIcon } from '@heroicons/react/24/solid' import cn from 'classnames' import s from './style.module.css' import type { ConversationItem } from '@/models/share' import { fetchConversations } from '@/service/share' import ItemOperation from '@/app/components/explore/item-operation' export type IListProps = { className: string currentId: string onCurrentIdChange: (id: string) => void list: ConversationItem[] isClearConversationList: boolean isInstalledApp: boolean installedAppId?: string onMoreLoaded: (res: { data: ConversationItem[]; has_more: boolean }) => void isNoMore: boolean isPinned: boolean onPinChanged: (id: string) => void controlUpdate: number onDelete: (id: string) => void } const List: FC = ({ className, currentId, onCurrentIdChange, list, isClearConversationList, isInstalledApp, installedAppId, onMoreLoaded, isNoMore, isPinned, onPinChanged, controlUpdate, onDelete, }) => { const listRef = useRef(null) useInfiniteScroll( async () => { if (!isNoMore) { let lastId = !isClearConversationList ? list[list.length - 1]?.id : undefined if (lastId === '-1') lastId = undefined const { data: conversations, has_more }: any = await fetchConversations(isInstalledApp, installedAppId, lastId, isPinned) onMoreLoaded({ data: conversations, has_more }) } return { list: [] } }, { target: listRef, isNoMore: () => { return isNoMore }, reloadDeps: [isNoMore, controlUpdate], }, ) return ( ) } export default React.memo(List)