Handle issues paging

This commit is contained in:
wpetit 2019-12-05 14:44:33 +01:00
parent 1f3f4bdeed
commit e5eb2e0a7e
2 changed files with 13 additions and 4 deletions

View File

@ -5,9 +5,18 @@ import { gitea } from '../../util/gitea';
export function* fetchIssuesSaga(action) {
const { project } = action;
let issues;
let issues = [];
try {
issues = yield call(gitea.fetchIssues.bind(gitea), action.project);
let page = 1;
while(true) {
let pageIssues = yield call(gitea.fetchIssues.bind(gitea), action.project, page);
if (pageIssues.length === 0) {
break;
}
issues.push(...pageIssues);
page++;
}
} catch(error) {
yield put({ type: FETCH_ISSUES_FAILURE, project, error });
return;

View File

@ -8,8 +8,8 @@ export class GiteaUnauthorizedError extends Error {
export class GiteaClient {
fetchIssues(project) {
return fetch(`/gitea/api/v1/repos/${project}/issues`)
fetchIssues(project, page = 1) {
return fetch(`/gitea/api/v1/repos/${project}/issues?page=${page}`)
.then(this.assertAuthorization)
.then(res => res.json())
;