@mjhls/mjh-framework 1.0.959-gridcontent-nojs-fix-v1 → 1.0.959-gridcontent-nojs-fix-v3

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.
@@ -87,7 +87,8 @@ var GridContent = function (_React$Component) {
87
87
  lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
88
88
  showCategory: _this.props.showCategory ? _this.props.showCategory : false,
89
89
  contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : [],
90
- lastDataSize: _this.data ? _this.data.length : 0
90
+ lastDataSize: _this.data ? _this.data.length : 0,
91
+ dataRemapped: !_this.props.showBI || !_this.props.brandInsight
91
92
  }, _this.loadMore = debounce.debounce_1(function () {
92
93
  _this.setState(function (state) {
93
94
  var page = state.page,
@@ -115,6 +116,10 @@ var GridContent = function (_React$Component) {
115
116
  if (pageview && currentPath !== prevPath) {
116
117
  pageview(currentPath);
117
118
  }
119
+ // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
120
+ if (typeof window !== 'undefined' && (!_this.props.lgInfeedAd || !_this.props.brandInsight || window.innerWidth < 1400) && !_this.state.dataRemapped) {
121
+ !_this.state.dataRemapped && _this.setState({ dataRemapped: true });
122
+ }
118
123
  }, _this.loadData = function () {
119
124
  var _this$state = _this.state,
120
125
  from = _this$state.from,
@@ -429,13 +434,13 @@ var GridContent = function (_React$Component) {
429
434
  });
430
435
 
431
436
  posts = lodash.lodash.flatten(chunks);
437
+ !this.state.dataRemapped && this.setState({ dataRemapped: true }); // To detect if appending of insights ads are completed
432
438
  }
433
439
 
434
440
  if (showBI) {
435
441
  // Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
436
442
  if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
437
443
  brandInsight.interval = 8;
438
- posts = data;
439
444
  } else if (typeof window !== 'undefined' && window.innerWidth < 1400) {
440
445
  brandInsight.interval = 5;
441
446
  posts = data;
@@ -495,6 +500,10 @@ var GridContent = function (_React$Component) {
495
500
  var itemsPerPage = this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
496
501
  var heroContent = this.props.heroContent ? this.props.heroContent : 0;
497
502
  var featureCount = 0;
503
+ if (!this.state.dataRemapped) {
504
+ //For Javascript Disabled Cases. data is not remapped if JS is disabled.
505
+ posts = this.state.data;
506
+ }
498
507
  return React__default['default'].createElement(
499
508
  'div',
500
509
  { className: 'grid-container' },
@@ -77,7 +77,8 @@ var GridContent = function (_React$Component) {
77
77
  lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
78
78
  showCategory: _this.props.showCategory ? _this.props.showCategory : false,
79
79
  contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : [],
80
- lastDataSize: _this.data ? _this.data.length : 0
80
+ lastDataSize: _this.data ? _this.data.length : 0,
81
+ dataRemapped: !_this.props.showBI || !_this.props.brandInsight
81
82
  }, _this.loadMore = debounce_1(function () {
82
83
  _this.setState(function (state) {
83
84
  var page = state.page,
@@ -105,6 +106,10 @@ var GridContent = function (_React$Component) {
105
106
  if (pageview && currentPath !== prevPath) {
106
107
  pageview(currentPath);
107
108
  }
109
+ // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
110
+ if (typeof window !== 'undefined' && (!_this.props.lgInfeedAd || !_this.props.brandInsight || window.innerWidth < 1400) && !_this.state.dataRemapped) {
111
+ !_this.state.dataRemapped && _this.setState({ dataRemapped: true });
112
+ }
108
113
  }, _this.loadData = function () {
109
114
  var _this$state = _this.state,
110
115
  from = _this$state.from,
@@ -419,13 +424,13 @@ var GridContent = function (_React$Component) {
419
424
  });
420
425
 
421
426
  posts = lodash.flatten(chunks);
427
+ !this.state.dataRemapped && this.setState({ dataRemapped: true }); // To detect if appending of insights ads are completed
422
428
  }
423
429
 
424
430
  if (showBI) {
425
431
  // Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
426
432
  if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
427
433
  brandInsight.interval = 8;
428
- posts = data;
429
434
  } else if (typeof window !== 'undefined' && window.innerWidth < 1400) {
430
435
  brandInsight.interval = 5;
431
436
  posts = data;
@@ -485,6 +490,10 @@ var GridContent = function (_React$Component) {
485
490
  var itemsPerPage = this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
486
491
  var heroContent = this.props.heroContent ? this.props.heroContent : 0;
487
492
  var featureCount = 0;
493
+ if (!this.state.dataRemapped) {
494
+ //For Javascript Disabled Cases. data is not remapped if JS is disabled.
495
+ posts = this.state.data;
496
+ }
488
497
  return React__default.createElement(
489
498
  'div',
490
499
  { className: 'grid-container' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.959-gridcontent-nojs-fix-v1",
3
+ "version": "1.0.959-gridcontent-nojs-fix-v3",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",