Merge pull request 'Prise en compte de la pagination sur la récupération des projets' (#44) from feature/fix-projects-fetch into develop
Reviewed-on: #44
This commit is contained in:
commit
0af54a0d52
|
@ -3,10 +3,18 @@ import { FETCH_PROJECTS_SUCCESS, FETCH_PROJECTS_FAILURE } from '../actions/proje
|
|||
import { gitea } from '../../util/gitea';
|
||||
|
||||
export function* fetchProjectsSaga() {
|
||||
|
||||
let projects;
|
||||
let projects = [];
|
||||
try {
|
||||
projects = yield call(gitea.fetchUserProjects.bind(gitea))
|
||||
let page = 1;
|
||||
while(true) {
|
||||
let pageProjects = yield call(gitea.fetchUserProjects.bind(gitea), page);
|
||||
if (pageProjects.length === 0) {
|
||||
break;
|
||||
}
|
||||
projects.push(...pageProjects);
|
||||
page++;
|
||||
}
|
||||
|
||||
} catch(error) {
|
||||
yield put({ type: FETCH_PROJECTS_FAILURE, error });
|
||||
return;
|
||||
|
|
|
@ -16,8 +16,8 @@ export class GiteaClient {
|
|||
;
|
||||
}
|
||||
|
||||
fetchUserProjects() {
|
||||
return fetch(`/gitea/api/v1/user/repos`)
|
||||
fetchUserProjects(page = 1) {
|
||||
return fetch(`/gitea/api/v1/user/repos?page=${page}`)
|
||||
.then(this.assertAuthorization)
|
||||
.then(this.assertOk)
|
||||
.then(res => res.json())
|
||||
|
|
Loading…
Reference in New Issue