forked from OpenBazaar/haven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
featured.js
31 lines (26 loc) · 842 Bytes
/
featured.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { call, put, takeEvery } from 'redux-saga/effects';
import { actions } from '../featured';
import { actions as profileActions } from '../profile';
import { fetchFeatured } from '../../api/featured';
export function* getFeatured() {
try {
const result = yield call(fetchFeatured);
yield put({ type: actions.setFeatured, payload: result });
for (let i = 0; i < result.length; i += 1) {
yield put({
type: profileActions.fetchProfile,
payload: {
peerID: result[i],
getLoaded: true,
},
});
}
} catch (err) {
console.log('Featured Saga Error: ', err);
}
yield put({ type: actions.setFeaturedLoading, payload: false });
}
const FeaturedSaga = function* Featured() {
yield takeEvery(actions.fetchFeatured, getFeatured);
};
export default FeaturedSaga;