1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 16:10:26 +00:00

optimized repo create code (#2697)

This commit is contained in:
杨顺强
2018-12-22 15:18:53 +08:00
committed by Daniel Pan
parent 7a2ce7bd16
commit eed617f44c
10 changed files with 123 additions and 95 deletions

View File

@@ -114,19 +114,21 @@ class PublicSharedView extends React.Component {
addRepoItem = (repo) => {
let isExist = false;
let repoIndex = 0;
let repoList = this.state.repoList;
for (let i = 0; i < repoList.length; i ++) {
if (repo.repo_id === repoList[i].repo_id) {
isExist = true;
repoIndex = i;
break;
}
}
if (isExist) {
return this.state.repoList;
this.state.repoList.splice(repoIndex, 1);
}
let newRepoList = this.state.repoList.map(item => {return item;});
newRepoList.push(repo);
newRepoList.unshift(repo);
return newRepoList;
}