1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-04 00:56:40 +07:00

fetching backend stats

This commit is contained in:
Fedor Katurov 2020-06-09 12:35:54 +07:00
parent d260325592
commit be3401a4e5
5 changed files with 46 additions and 8 deletions

View file

@ -1,16 +1,21 @@
import { takeLatest, put, call } from 'redux-saga/effects';
import { BORIS_ACTIONS } from './constants';
import { borisSet, borisSetStats } from './actions';
import { getBorisGitStats } from './api';
import { borisSetStats } from './actions';
import { getBorisGitStats, getBorisBackendStats } from './api';
import { Unwrap } from '../types';
function* loadStats() {
yield put(borisSetStats({ is_loading: true }));
try {
const git = yield getBorisGitStats();
yield put(borisSetStats({ git, is_loading: false }));
const git: Unwrap<ReturnType<typeof getBorisGitStats>> = yield call(getBorisGitStats);
const backend: Unwrap<ReturnType<typeof getBorisBackendStats>> = yield call(
getBorisBackendStats
);
yield put(borisSetStats({ git, backend: backend.data, is_loading: false }));
} catch (e) {
yield put(borisSetStats({ git: [], is_loading: false }));
yield put(borisSetStats({ git: [], backend: null, is_loading: false }));
}
}