fix(fe/files): sort items at initing

This commit is contained in:
hexxa 2021-12-12 15:03:31 +08:00 committed by Hexxa
parent d66b854f83
commit 9bf30f9677

View file

@ -387,18 +387,18 @@ export class FilesPanel extends React.Component<Props, State, {}> {
</div>
);
// 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("/")