mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 00:43:53 +00:00
update new file postion arithmetic (#2776)
This commit is contained in:
@@ -469,10 +469,27 @@ class DirView extends React.Component {
|
|||||||
if (type === 'dir') {
|
if (type === 'dir') {
|
||||||
direntList.unshift(dirent);
|
direntList.unshift(dirent);
|
||||||
return direntList;
|
return direntList;
|
||||||
}
|
} else { // type === 'file'
|
||||||
|
// 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(dirent);
|
direntList.push(dirent);
|
||||||
|
} else {
|
||||||
|
let index = 0;
|
||||||
|
for (let i = 0; i <= length; i++) {
|
||||||
|
if (direntList[i].type === 'file') {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
direntList.splice(index, 0, dirent);
|
||||||
|
}
|
||||||
return direntList;
|
return direntList;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deleteItem = (dirent) => {
|
deleteItem = (dirent) => {
|
||||||
return this.state.direntList.filter(item => {
|
return this.state.direntList.filter(item => {
|
||||||
|
@@ -546,7 +546,23 @@ class Wiki extends Component {
|
|||||||
if (type === 'dir') {
|
if (type === 'dir') {
|
||||||
direntList.unshift(item);
|
direntList.unshift(item);
|
||||||
} else {
|
} else {
|
||||||
|
// 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);
|
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});
|
this.setState({direntList: direntList});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user