1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-11 03:41:12 +00:00

update homepage get repo (#6077)

* Merge to get repo API

* add-public-repo-list

---------

Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com>
Co-authored-by: r350178982 <32759763+r350178982@users.noreply.github.com>
This commit is contained in:
awu0403
2024-05-16 16:19:49 +08:00
committed by GitHub
parent 06de95840b
commit 6bd8d6dade
3 changed files with 77 additions and 31 deletions

View File

@@ -16,7 +16,8 @@ import TopToolbar from './top-toolbar';
const propTypes = {
onShowSidePanel: PropTypes.func,
onSearchedClick: PropTypes.func,
inAllLibs: PropTypes.bool
inAllLibs: PropTypes.bool,
repoList: PropTypes.array,
};
class PublicSharedView extends React.Component {
@@ -35,21 +36,27 @@ class PublicSharedView extends React.Component {
}
componentDidMount() {
seafileAPI.listRepos({type: 'public'}).then((res) => {
let repoList = res.data.repos.map(item => {
let repo = new Repo(item);
return repo;
if (!this.props.repoList) {
seafileAPI.listRepos({type:'public'}).then((res) => {
let repoList = res.data.repos.map((item) => {
return new Repo(item);
});
this.setState({
isLoading: false,
repoList: Utils.sortRepos(repoList, this.state.sortBy, this.state.sortOrder)
});
}).catch((error) => {
this.setState({
isLoading: false,
errMessage: Utils.getErrorMsg(error, true)
});
});
} else {
this.setState({
isLoading: false,
repoList: Utils.sortRepos(repoList, this.state.sortBy, this.state.sortOrder)
repoList: Utils.sortRepos(this.props.repoList, this.state.sortBy, this.state.sortOrder)
});
}).catch((error) => {
this.setState({
isLoading: false,
errorMsg: Utils.getErrorMsg(error, true) // true: show login tip if 403
});
});
}
}
onItemUnshare = (repo) => {