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:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user