actionCatByIdFull.js 966 B

1234567891011121314151617181920212223
  1. import { call, put, take } from "redux-saga/effects";
  2. import { actionFeedClear, actionPromiseClear } from "../reducers";
  3. import { actionFeedCategoryGoods } from "../reducers/feedReducer";
  4. import { promiseWorker } from "../reducers/promiseReducer";
  5. import { actionCatById } from "./actionCatById";
  6. import { actionPromisesClear } from "./actionPromisesClear";
  7. export const actionCatByIdFull = ({ _id, orderBy }) => ({ type: "CAT_BY_ID_FULL", payload: { _id, orderBy } });
  8. export function* catByIdFullWorker(action) {
  9. const { _id, orderBy = "createdAt" } = action.payload || {};
  10. const category = yield call(promiseWorker, actionCatById({ _id }));
  11. yield put(actionFeedClear());
  12. yield put(actionPromiseClear("feedCategoryGoods"));
  13. yield put(actionFeedCategoryGoods({ category, orderBy, skip: 0 }));
  14. yield take("CAT_BY_ID_FULL_CLEAR");
  15. yield put(actionPromisesClear(["catById", "feedCategoryGoods"]));
  16. yield put(actionFeedClear());
  17. }