fix: prevent empty-state flash on knowledge-base and chat list loading (#17221)

This commit is contained in:
euvre
2026-07-22 19:20:48 +08:00
committed by GitHub
parent 769bd50363
commit c1aff8c710
4 changed files with 24 additions and 10 deletions

View File

@@ -81,7 +81,7 @@ export const useFetchChatList = () => {
...pagination,
},
],
initialData: { chats: [], total: 0 },
placeholderData: (previousData) => previousData ?? { chats: [], total: 0 },
gcTime: 0,
refetchOnWindowFocus: false,
queryFn: async () => {

View File

@@ -169,10 +169,8 @@ export const useFetchNextKnowledgeListByPage = () => {
filterValue,
},
],
initialData: {
kbs: [],
total_datasets: 0,
},
placeholderData: (previousData) =>
previousData ?? { kbs: [], total_datasets: 0 },
gcTime: 0,
queryFn: async () => {
const { data } = await listDataset({

View File

@@ -5,6 +5,7 @@ import ListFilterBar from '@/components/list-filter-bar';
import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
import { Spin } from '@/components/ui/spin';
import { useFetchNextKnowledgeListByPage } from '@/hooks/use-knowledge-request';
import { useQueryClient } from '@tanstack/react-query';
import { pick } from 'lodash';
@@ -37,6 +38,7 @@ export default function Datasets() {
searchString,
filterValue,
handleFilterSubmit,
loading,
} = useFetchNextKnowledgeListByPage();
const owners = useSelectOwners();
@@ -70,7 +72,14 @@ export default function Datasets() {
return (
<>
{kbs?.length || searchString ? (
{loading && !kbs?.length ? (
<article
className="size-full flex items-center justify-center"
data-testid="datasets-list"
>
<Spin size="large" />
</article>
) : kbs?.length || searchString ? (
<article
className="size-full min-w-0 flex flex-col"
data-testid="datasets-list"

View File

@@ -5,6 +5,7 @@ import ListFilterBar from '@/components/list-filter-bar';
import { RenameDialog } from '@/components/rename-dialog';
import { Button } from '@/components/ui/button';
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
import { Spin } from '@/components/ui/spin';
import { useFetchChatList } from '@/hooks/use-chat-request';
import { buildOwnersFilter } from '@/utils/list-filter-util';
import { pick } from 'lodash';
@@ -25,12 +26,11 @@ export default function ChatList() {
searchString,
filterValue,
handleFilterSubmit,
loading,
} = useFetchChatList();
const { t } = useTranslation();
const { t: tc } = useTranslation('common');
const owners = [
buildOwnersFilter(data?.chats ?? [], undefined, tc('owner')),
];
const owners = [buildOwnersFilter(data?.chats ?? [], undefined, tc('owner'))];
const {
initialChatName,
chatRenameVisible,
@@ -103,7 +103,14 @@ export default function ChatList() {
return (
<>
{data.chats?.length || searchString ? (
{loading && !data.chats?.length ? (
<article
className="size-full flex items-center justify-center"
data-testid="chats-list"
>
<Spin size="large" />
</article>
) : data.chats?.length || searchString ? (
<article
className="size-full min-w-0 flex flex-col"
data-testid="chats-list"