1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 08:28:11 +00:00

update new file postion arithmetic (#2776)

This commit is contained in:
杨顺强
2019-01-07 12:41:24 +08:00
committed by Daniel Pan
parent d561acd24f
commit d3d4650071
2 changed files with 36 additions and 3 deletions

View File

@@ -546,7 +546,23 @@ class Wiki extends Component {
if (type === 'dir') {
direntList.unshift(item);
} else {
direntList.push(item);
// there will be there conditions;
// first: direntList.length === 0;
// second: all the direntList's items are dir;
// third: direntList has dir and file;
let length = direntList.length
if (length === 0 || direntList[length - 1].type === 'dir') {
direntList.push(item);
} else {
let index = 0;
for (let i = 0; i <= length; i++) {
if (direntList[i].type === 'file') {
index = i;
break;
}
}
direntList.splice(index, 0, item);
}
}
this.setState({direntList: direntList});
}