2019-12-01 22:12:13 +01:00
|
|
|
import { put, call } from 'redux-saga/effects';
|
|
|
|
import { FETCH_PROJECTS_SUCCESS, FETCH_PROJECTS_FAILURE } from '../actions/projects';
|
|
|
|
import { gitea } from '../../util/gitea';
|
|
|
|
|
|
|
|
export function* fetchProjectsSaga() {
|
2021-04-02 10:54:49 +02:00
|
|
|
let projects = [];
|
2019-12-01 22:12:13 +01:00
|
|
|
try {
|
2021-04-02 10:54:49 +02:00
|
|
|
let page = 1;
|
|
|
|
while(true) {
|
|
|
|
let pageProjects = yield call(gitea.fetchUserProjects.bind(gitea), page);
|
|
|
|
if (pageProjects.length === 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
projects.push(...pageProjects);
|
|
|
|
page++;
|
|
|
|
}
|
|
|
|
|
2019-12-01 22:12:13 +01:00
|
|
|
} catch(error) {
|
|
|
|
yield put({ type: FETCH_PROJECTS_FAILURE, error });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
yield put({ type: FETCH_PROJECTS_SUCCESS, projects });
|
|
|
|
}
|