From 10c964ba36715cf97656a959e4820572380f3889 Mon Sep 17 00:00:00 2001 From: Xianquan Date: Fri, 31 Jul 2026 18:27:12 +0800 Subject: [PATCH] fix(chat): stop single quote pagination loop --- packages/web/hooks/useLinkedScroll.tsx | 12 +++++++++--- .../chat/ChatQuoteList/CollectionQuoteReader.tsx | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/web/hooks/useLinkedScroll.tsx b/packages/web/hooks/useLinkedScroll.tsx index ddda9d9ebc5b..87a2e003ba16 100644 --- a/packages/web/hooks/useLinkedScroll.tsx +++ b/packages/web/hooks/useLinkedScroll.tsx @@ -8,6 +8,10 @@ import { useRequest } from './useRequest'; const threshold = 200; +/** + * 加载以锚点为中心的关联列表,并按滚动位置补充前后数据。 + * 关闭分页时仍保留滚动容器和初始锚点请求,适用于只展示单条数据的场景。 + */ export function useLinkedScroll< TParams extends LinkedPaginationProps, TData extends LinkedListResponse @@ -18,12 +22,14 @@ export function useLinkedScroll< params = {}, currentData, defaultScroll = 'top', + enablePagination = true, showErrorToast = true }: { pageSize?: number; params?: Record; currentData?: { id: string; anchor?: any }; defaultScroll?: 'top' | 'bottom'; + enablePagination?: boolean; showErrorToast?: boolean; } ) { @@ -246,7 +252,7 @@ export function useLinkedScroll< useDebounceEffect( () => { - if (!actualContainerRef?.current || isLoading) return; + if (!enablePagination || !actualContainerRef?.current || isLoading) return; const { scrollTop, scrollHeight, clientHeight } = actualContainerRef.current; @@ -260,7 +266,7 @@ export function useLinkedScroll< loadPrevData(actualContainerRef); } }, - [scroll], + [scroll, enablePagination], { wait: 200 } ); @@ -280,7 +286,7 @@ export function useLinkedScroll< ); }, - [isLoading] + [enablePagination, isLoading] ); return { diff --git a/projects/app/src/pageComponents/chat/ChatQuoteList/CollectionQuoteReader.tsx b/projects/app/src/pageComponents/chat/ChatQuoteList/CollectionQuoteReader.tsx index 774434c96a61..2fc56474c177 100644 --- a/projects/app/src/pageComponents/chat/ChatQuoteList/CollectionQuoteReader.tsx +++ b/projects/app/src/pageComponents/chat/ChatQuoteList/CollectionQuoteReader.tsx @@ -111,7 +111,8 @@ const CollectionReader = ({ loadInitData } = useLinkedScroll(getCollectionQuote, { params, - currentData: currentQuoteItem + currentData: currentQuoteItem, + enablePagination: !singleQuote }); const isDeleted = useMemo(