"use strict";

exports.__esModule = true;
exports.useSyncTotal = void 0;
var _react = require("react");
var _providers = require("../providers");
var _mobx = require("mobx");
const useSyncTotal = state => {
  const pageState = (0, _providers.useCollectionPageContext)();
  (0, _react.useEffect)(() => {
    if (state.totalStatus === 'success') {
      (0, _mobx.runInAction)(() => {
        pageState.total = state.total;
      });
    }
    return (0, _mobx.reaction)(() => ({
      status: state.totalStatus,
      total: state.total
    }), ({
      status,
      total
    }) => {
      pageState.total = status === 'success' ? total : false;
    });
  }, []);
};
exports.useSyncTotal = useSyncTotal;
//# sourceMappingURL=useSyncTotal.js.map