@mjhls/mjh-framework 1.0.125 → 1.0.127

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9165,6 +9165,35 @@ var main_47 = main.osName;
9165
9165
  var main_48 = main.osVersion;
9166
9166
  var main_49 = main.withOrientationChange;
9167
9167
 
9168
+ var asyncToGenerator = function (fn) {
9169
+ return function () {
9170
+ var gen = fn.apply(this, arguments);
9171
+ return new Promise(function (resolve, reject) {
9172
+ function step(key, arg) {
9173
+ try {
9174
+ var info = gen[key](arg);
9175
+ var value = info.value;
9176
+ } catch (error) {
9177
+ reject(error);
9178
+ return;
9179
+ }
9180
+
9181
+ if (info.done) {
9182
+ resolve(value);
9183
+ } else {
9184
+ return Promise.resolve(value).then(function (value) {
9185
+ step("next", value);
9186
+ }, function (err) {
9187
+ step("throw", err);
9188
+ });
9189
+ }
9190
+ }
9191
+
9192
+ return step("next");
9193
+ });
9194
+ };
9195
+ };
9196
+
9168
9197
  var classCallCheck = function (instance, Constructor) {
9169
9198
  if (!(instance instanceof Constructor)) {
9170
9199
  throw new TypeError("Cannot call a class as a function");
@@ -12692,43 +12721,57 @@ var MasterDeck = function (_React$Component) {
12692
12721
  to: to + per
12693
12722
  };
12694
12723
  }, _this.loadData);
12695
- }, 0), _this.loadData = function () {
12696
- var _this$state = _this.state,
12697
- from = _this$state.from,
12698
- to = _this$state.to,
12699
- data = _this$state.data,
12700
- query = _this$state.query,
12701
- page = _this$state.page;
12702
- var client = _this.props.client;
12724
+ }, 0), _this.loadData = asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
12725
+ var _this$state, from, to, data, query, page, _this$props, client, dataHandler, params;
12703
12726
 
12727
+ return regeneratorRuntime.wrap(function _callee$(_context) {
12728
+ while (1) {
12729
+ switch (_context.prev = _context.next) {
12730
+ case 0:
12731
+ _this$state = _this.state, from = _this$state.from, to = _this$state.to, data = _this$state.data, query = _this$state.query, page = _this$state.page;
12732
+ _this$props = _this.props, client = _this$props.client, dataHandler = _this$props.dataHandler;
12733
+ params = _extends({}, _this.params, { from: from, to: to });
12704
12734
 
12705
- var params = _extends({}, _this.params, { from: from, to: to
12706
- // const queryUpdated = query.replace('$from', params.from).replace('$to', params.to)
12707
- // const query = '*[_type == "article" && defined(title) && defined(thumbnail)][$from...$to] { title, summary, thumbnail { asset-> }, url }'
12708
- });client.fetch(query, params).then(function (dataArr) {
12709
- if (_this.pointer && _this.pointerArray) {
12710
- var pointer = _this.pointer;
12711
- dataArr = dataArr[_this.pointerArray][pointer];
12712
- }
12713
- dataArr = dataArr.map(function (item) {
12714
- return _extends({}, item, {
12715
- pageNumber: page
12716
- });
12717
- });
12718
12735
 
12719
- _this.setState(function () {
12720
- if (dataArr.length > 0) {
12721
- return {
12722
- data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12723
- scrolling: true
12724
- };
12725
- } else {
12726
- return {
12727
- scrolling: false
12728
- };
12736
+ if (dataHandler) {
12737
+ dataHandler.then(function (dataArr) {
12738
+ loadDataFinished(data, dataArr, page);
12739
+ });
12740
+ } else {
12741
+ client.fetch(query, params).then(function (dataArr) {
12742
+ loadDataFinished(data, dataArr, page);
12743
+ });
12744
+ }
12745
+
12746
+ case 4:
12747
+ case 'end':
12748
+ return _context.stop();
12729
12749
  }
12750
+ }
12751
+ }, _callee, _this2);
12752
+ })), _this.loadDataFinished = function (data, dataArr, page) {
12753
+ if (_this.pointer && _this.pointerArray) {
12754
+ var pointer = _this.pointer;
12755
+ dataArr = dataArr[_this.pointerArray][pointer];
12756
+ }
12757
+ dataArr = dataArr.map(function (item) {
12758
+ return _extends({}, item, {
12759
+ pageNumber: page
12730
12760
  });
12731
12761
  });
12762
+
12763
+ _this.setState(function () {
12764
+ if (dataArr.length > 0) {
12765
+ return {
12766
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12767
+ scrolling: true
12768
+ };
12769
+ } else {
12770
+ return {
12771
+ scrolling: false
12772
+ };
12773
+ }
12774
+ });
12732
12775
  }, _this.urlFor = function (source) {
12733
12776
  var client = _this.props.client;
12734
12777
 
@@ -12745,10 +12788,10 @@ var MasterDeck = function (_React$Component) {
12745
12788
  }
12746
12789
  }, _this.changePageNumber = function (pageNumber) {
12747
12790
  console.log(pageNumber);
12748
- var _this$props = _this.props,
12749
- seoPaginate = _this$props.seoPaginate,
12750
- pageview = _this$props.pageview,
12751
- router$$1 = _this$props.router;
12791
+ var _this$props2 = _this.props,
12792
+ seoPaginate = _this$props2.seoPaginate,
12793
+ pageview = _this$props2.pageview,
12794
+ router$$1 = _this$props2.router;
12752
12795
  var currentPage = _this.state.currentPage;
12753
12796
 
12754
12797
  if (seoPaginate) {