mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
24 lines
806 B
TypeScript
24 lines
806 B
TypeScript
import { call, put, takeLatest } from 'redux-saga/effects';
|
|
import { BORIS_ACTIONS } from './constants';
|
|
import { borisSetStats } from './actions';
|
|
import { getBorisBackendStats, getGithubIssues } from './api';
|
|
import { Unwrap } from '../types';
|
|
|
|
function* loadStats() {
|
|
try {
|
|
yield put(borisSetStats({ is_loading: true }));
|
|
|
|
const backend: Unwrap<typeof getBorisBackendStats> = yield call(getBorisBackendStats);
|
|
const issues: Unwrap<typeof getGithubIssues> = yield call(getGithubIssues);
|
|
|
|
yield put(borisSetStats({ issues, backend }));
|
|
} catch (e) {
|
|
yield put(borisSetStats({ git: [], backend: undefined }));
|
|
} finally {
|
|
yield put(borisSetStats({ is_loading: false }));
|
|
}
|
|
}
|
|
|
|
export default function* borisSaga() {
|
|
yield takeLatest(BORIS_ACTIONS.LOAD_STATS, loadStats);
|
|
}
|