@mjhls/mjh-framework 1.0.125 → 1.0.126

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
@@ -12699,35 +12699,52 @@ var MasterDeck = function (_React$Component) {
12699
12699
  data = _this$state.data,
12700
12700
  query = _this$state.query,
12701
12701
  page = _this$state.page;
12702
- var client = _this.props.client;
12702
+ var _this$props = _this.props,
12703
+ client = _this$props.client,
12704
+ dataHandler = _this$props.dataHandler;
12703
12705
 
12704
12706
 
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
- });
12707
+ var params = _extends({}, _this.params, { from: from, to: to });
12718
12708
 
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
- };
12709
+ if (dataHandler) {
12710
+ var dataHandlerPromise = new Promise(function (resolve, reject) {
12711
+ try {
12712
+ var result = dataHandler(params);
12713
+ resolve(result);
12714
+ } catch (e) {
12715
+ reject(e);
12729
12716
  }
12730
12717
  });
12718
+ dataHandlerPromise.then(function (dataArr) {
12719
+ loadDataFinished(data, dataArr, page);
12720
+ });
12721
+ } else {
12722
+ client.fetch(query, params).then(function (dataArr) {
12723
+ loadDataFinished(data, dataArr, page);
12724
+ });
12725
+ }
12726
+ }, _this.loadDataFinished = function (data, dataArr, page) {
12727
+ if (_this.pointer && _this.pointerArray) {
12728
+ var pointer = _this.pointer;
12729
+ dataArr = dataArr[_this.pointerArray][pointer];
12730
+ }
12731
+ dataArr = dataArr.map(function (item) {
12732
+ return _extends({}, item, {
12733
+ pageNumber: page
12734
+ });
12735
+ });
12736
+
12737
+ _this.setState(function () {
12738
+ if (dataArr.length > 0) {
12739
+ return {
12740
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12741
+ scrolling: true
12742
+ };
12743
+ } else {
12744
+ return {
12745
+ scrolling: false
12746
+ };
12747
+ }
12731
12748
  });
12732
12749
  }, _this.urlFor = function (source) {
12733
12750
  var client = _this.props.client;
@@ -12745,10 +12762,10 @@ var MasterDeck = function (_React$Component) {
12745
12762
  }
12746
12763
  }, _this.changePageNumber = function (pageNumber) {
12747
12764
  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;
12765
+ var _this$props2 = _this.props,
12766
+ seoPaginate = _this$props2.seoPaginate,
12767
+ pageview = _this$props2.pageview,
12768
+ router$$1 = _this$props2.router;
12752
12769
  var currentPage = _this.state.currentPage;
12753
12770
 
12754
12771
  if (seoPaginate) {