From 1f3217c3c54ff3a59244b1ea3c1b2e12a60f7fb1 Mon Sep 17 00:00:00 2001 From: Mrxbox98 <29240392+mrxbox98@users.noreply.github.com> Date: Tue, 18 Jan 2022 11:49:06 -0800 Subject: [PATCH] fix(server/files): duplicate entry when making a nested folder (#3813) --- .../scripts/components/server/files/FileManagerContainer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/scripts/components/server/files/FileManagerContainer.tsx b/resources/scripts/components/server/files/FileManagerContainer.tsx index 0e5b10645..47910b8c3 100644 --- a/resources/scripts/components/server/files/FileManagerContainer.tsx +++ b/resources/scripts/components/server/files/FileManagerContainer.tsx @@ -22,8 +22,8 @@ import { FileActionCheckbox } from '@/components/server/files/SelectFileCheckbox import { hashToPath } from '@/helpers'; const sortFiles = (files: FileObject[]): FileObject[] => { - return files.sort((a, b) => a.name.localeCompare(b.name)) - .sort((a, b) => a.isFile === b.isFile ? 0 : (a.isFile ? 1 : -1)); + const sortedFiles: FileObject[] = files.sort((a, b) => a.name.localeCompare(b.name)).sort((a, b) => a.isFile === b.isFile ? 0 : (a.isFile ? 1 : -1)); + return sortedFiles.filter((file, index) => index === 0 || file.name !== sortedFiles[index - 1].name); }; export default () => {