From 9bf30f96779e21b5d7e27808cc95e779543e7478 Mon Sep 17 00:00:00 2001 From: hexxa Date: Sun, 12 Dec 2021 15:03:31 +0800 Subject: [PATCH] fix(fe/files): sort items at initing --- src/client/web/src/components/panel_files.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/client/web/src/components/panel_files.tsx b/src/client/web/src/components/panel_files.tsx index 347cd85..c425881 100644 --- a/src/client/web/src/components/panel_files.tsx +++ b/src/client/web/src/components/panel_files.tsx @@ -387,18 +387,18 @@ export class FilesPanel extends React.Component { ); - // const sortedItems = this.props.filesInfo.items.sort( - // (item1: MetadataResp, item2: MetadataResp) => { - // if (item1.isDir && !item2.isDir) { - // return -1; - // } else if (!item1.isDir && item2.isDir) { - // return 1; - // } - // return 0; - // } - // ); + const sortedItems = this.props.filesInfo.items.sort( + (item1: MetadataResp, item2: MetadataResp) => { + if (item1.isDir && !item2.isDir) { + return -1; + } else if (!item1.isDir && item2.isDir) { + return 1; + } + return 0; + } + ); - const items = this.props.filesInfo.items.map((item: MetadataResp) => { + const items = sortedItems.map((item: MetadataResp) => { const isSelected = this.state.selectedItems.has(item.name); const dirPath = this.props.filesInfo.dirPath.join("/"); const itemPath = dirPath.endsWith("/")