From 79518973e51f0951e2d2d4ef123c4b2037c992e8 Mon Sep 17 00:00:00 2001 From: chanx <1243304602@qq.com> Date: Fri, 3 Jul 2026 16:13:57 +0800 Subject: [PATCH] Fix: optimize folder data handling in MoveDialog component (#16580) --- web/src/pages/files/move-dialog.tsx | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) 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) { const { t } = useTranslation(); @@ -31,22 +32,28 @@ export function MoveDialog({ hideModal, onOk, loading }: IModalProps) { 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', + ); }); } },