Handle issues paging
This commit is contained in:
parent
1f3f4bdeed
commit
e5eb2e0a7e
|
@ -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;
|
||||
|
|
|
@ -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())
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue