Prise en compte de la pagination sur la récupération des projets #44

Merged
wpetit merged 1 commits from feature/fix-projects-fetch into develop 2021-04-02 10:57:24 +02:00
2 changed files with 13 additions and 5 deletions
Showing only changes of commit d8dcf636ea - Show all commits

View File

@ -3,10 +3,18 @@ import { FETCH_PROJECTS_SUCCESS, FETCH_PROJECTS_FAILURE } from '../actions/proje
import { gitea } from '../../util/gitea'; import { gitea } from '../../util/gitea';
export function* fetchProjectsSaga() { export function* fetchProjectsSaga() {
let projects = [];
let projects;
try { 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) { } catch(error) {
yield put({ type: FETCH_PROJECTS_FAILURE, error }); yield put({ type: FETCH_PROJECTS_FAILURE, error });
return; return;

View File

@ -16,8 +16,8 @@ export class GiteaClient {
; ;
} }
fetchUserProjects() { fetchUserProjects(page = 1) {
return fetch(`/gitea/api/v1/user/repos`) return fetch(`/gitea/api/v1/user/repos?page=${page}`)
.then(this.assertAuthorization) .then(this.assertAuthorization)
.then(this.assertOk) .then(this.assertOk)
.then(res => res.json()) .then(res => res.json())