Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: optimize folder data handling in MoveDialog component (#16580)

chanx79518973e51f
diff --git a/web/src/pages/files/move-dialog.tsx b/web/src/pages/files/move-dialog.tsx
index 4f8d06e1d8..c73b5c7613 100644
--- a/web/src/pages/files/move-dialog.tsx
+++ b/web/src/pages/files/move-dialog.tsx
@@ -13,9 +13,10 @@ import {
import { useFetchPureFileList } from '@/hooks/use-file-request';
import { IModalProps } from '@/interfaces/common';
import { IFile } from '@/interfaces/database/file-manager';
-import { isEmpty } from 'lodash';
+import { isEmpty, uniqBy } from 'lodash';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { isFolderType } from './util';
export function MoveDialog({ hideModal, onOk, loading }: IModalProps<any>) {
const { t } = useTranslation();
@@ -31,22 +32,28 @@ export function MoveDialog({ hideModal, onOk, loading }: IModalProps<any>) {
const ret = await fetchList(id as string);
if (ret.code === 0) {
setTreeData((tree) => {
- const existingIds = new Set(tree.map((n) => n.id));
- const newNodes = ret.data.files
- .filter(
- (x: IFile) =>
- x.type === 'folder' && !existingIds.has(x.id),
- )
- .map((x: IFile) => ({
- id: x.id,
- parentId: x.parent_id,
- title: x.name,
- isLeaf:
- typeof x.has_child_folder === 'boolean'
- ? !x.has_child_folder
- : false,
- }));
- return tree.concat(newNodes);
+ return uniqBy(
+ tree.concat(
+ ret.data.files
+ .filter(
+ (x: IFile) =>
+ x.type === 'folder' &&
+ !(
+ isFolderType(x.type) && x.name.toLowerCase() === 'skills'
+ ),
+ )
+ .map((x: IFile) => ({
+ id: x.id,
+ parentId: x.parent_id,
+ title: x.name,
+ isLeaf:
+ typeof x.has_child_folder === 'boolean'
+ ? !x.has_child_folder
+ : false,
+ })),
+ ),
+ 'id',
+ );
});
}
},