index.js 973 B

123456789101112131415161718192021222324252627
  1. import { put, takeLeading, call } from 'redux-saga/effects'
  2. import { actionProfilePageDataUserType } from '../../../actions/types/userTypes'
  3. import { promiseWorker } from '../promise'
  4. import {
  5. actionUserAllPostsType,
  6. actionCountPostsType,
  7. } from '../../../actions/types/postTypes'
  8. import {
  9. actionAboutUser,
  10. actionAllPostsUser,
  11. actionPostsCount,
  12. } from '../../../actions/query/aboutUserQuery'
  13. export function* fullPageAboutUserWorker({ _id }) {
  14. const aboutUser = yield call(promiseWorker, actionAboutUser(_id))
  15. const allPosts = yield call(promiseWorker, actionAllPostsUser(_id))
  16. const countPosts = yield call(promiseWorker, actionPostsCount(_id))
  17. if (aboutUser) yield put(actionProfilePageDataUserType(aboutUser))
  18. if (allPosts) {
  19. yield put(actionUserAllPostsType(allPosts))
  20. }
  21. if (countPosts) yield put(actionCountPostsType(countPosts))
  22. }
  23. export function* fullPageAboutUserWatcher() {
  24. yield takeLeading('USER_PAGE', fullPageAboutUserWorker)
  25. }