@mjhls/mjh-framework 1.0.939-segment-test-v6 → 1.0.939-segment-test-v7
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/cjs/View.js +18 -45
- package/dist/esm/View.js +18 -45
- package/package.json +1 -1
package/dist/cjs/View.js
CHANGED
|
@@ -461,9 +461,7 @@ var Recommended = function Recommended(props) {
|
|
|
461
461
|
client = props.client,
|
|
462
462
|
_props$index = props.index,
|
|
463
463
|
index = _props$index === undefined ? 0 : _props$index,
|
|
464
|
-
cpModificationRequired = props.cpModificationRequired
|
|
465
|
-
segmentData = props.segmentData,
|
|
466
|
-
setSegmentData = props.setSegmentData;
|
|
464
|
+
cpModificationRequired = props.cpModificationRequired;
|
|
467
465
|
|
|
468
466
|
var _useState = React.useState(false),
|
|
469
467
|
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
|
@@ -509,48 +507,29 @@ var Recommended = function Recommended(props) {
|
|
|
509
507
|
// get users traits
|
|
510
508
|
var getSegmentProfile = function () {
|
|
511
509
|
var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
|
|
512
|
-
var
|
|
510
|
+
var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
|
|
513
511
|
|
|
514
512
|
return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
|
|
515
513
|
while (1) {
|
|
516
514
|
switch (_context.prev = _context.next) {
|
|
517
515
|
case 0:
|
|
518
|
-
data = void 0;
|
|
519
|
-
|
|
520
|
-
if (segmentData) {
|
|
521
|
-
_context.next = 12;
|
|
522
|
-
break;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
516
|
anonymousId = analytics.user().anonymousId();
|
|
526
|
-
_context.next =
|
|
517
|
+
_context.next = 3;
|
|
527
518
|
return fetch('/api/getSegmentProfile', {
|
|
528
519
|
method: 'POST',
|
|
529
520
|
body: stringify._JSON$stringify({ anonymousId: anonymousId })
|
|
530
521
|
});
|
|
531
522
|
|
|
532
|
-
case
|
|
523
|
+
case 3:
|
|
533
524
|
response = _context.sent;
|
|
534
|
-
_context.next =
|
|
525
|
+
_context.next = 6;
|
|
535
526
|
return response.json();
|
|
536
527
|
|
|
537
|
-
case
|
|
528
|
+
case 6:
|
|
538
529
|
data = _context.sent;
|
|
539
530
|
|
|
540
|
-
if (data && data.traits && data.traits.favorite_article_category) {
|
|
541
|
-
setSegmentData(data);
|
|
542
|
-
} else {
|
|
543
|
-
setLoaded('failed');
|
|
544
|
-
}
|
|
545
|
-
_context.next = 13;
|
|
546
|
-
break;
|
|
547
|
-
|
|
548
|
-
case 12:
|
|
549
|
-
data = segmentData;
|
|
550
|
-
|
|
551
|
-
case 13:
|
|
552
531
|
if (!(data && data.traits && data.traits.favorite_article_category)) {
|
|
553
|
-
_context.next =
|
|
532
|
+
_context.next = 24;
|
|
554
533
|
break;
|
|
555
534
|
}
|
|
556
535
|
|
|
@@ -581,10 +560,10 @@ var Recommended = function Recommended(props) {
|
|
|
581
560
|
params = {
|
|
582
561
|
id: article._id
|
|
583
562
|
};
|
|
584
|
-
_context.next =
|
|
563
|
+
_context.next = 16;
|
|
585
564
|
return asyncToGenerator._Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
|
|
586
565
|
|
|
587
|
-
case
|
|
566
|
+
case 16:
|
|
588
567
|
_ref2 = _context.sent;
|
|
589
568
|
_ref3 = slicedToArray._slicedToArray(_ref2, 3);
|
|
590
569
|
_articles = _ref3[0];
|
|
@@ -603,8 +582,13 @@ var Recommended = function Recommended(props) {
|
|
|
603
582
|
}
|
|
604
583
|
setArticles(_articles);
|
|
605
584
|
}
|
|
585
|
+
_context.next = 25;
|
|
586
|
+
break;
|
|
606
587
|
|
|
607
|
-
case
|
|
588
|
+
case 24:
|
|
589
|
+
setLoaded('failed');
|
|
590
|
+
|
|
591
|
+
case 25:
|
|
608
592
|
case 'end':
|
|
609
593
|
return _context.stop();
|
|
610
594
|
}
|
|
@@ -931,11 +915,7 @@ var Article = React__default['default'].memo(React.forwardRef(function (props, r
|
|
|
931
915
|
_props$downloadCitati = props.downloadCitation,
|
|
932
916
|
downloadCitation = _props$downloadCitati === undefined ? false : _props$downloadCitati,
|
|
933
917
|
_props$useSegmentReco = props.useSegmentRecommendedArticles,
|
|
934
|
-
useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco
|
|
935
|
-
_props$segmentData = props.segmentData,
|
|
936
|
-
segmentData = _props$segmentData === undefined ? null : _props$segmentData,
|
|
937
|
-
_props$setSegmentData = props.setSegmentData,
|
|
938
|
-
setSegmentData = _props$setSegmentData === undefined ? function () {} : _props$setSegmentData;
|
|
918
|
+
useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco;
|
|
939
919
|
var sliderData = props.sliderData;
|
|
940
920
|
|
|
941
921
|
|
|
@@ -1170,7 +1150,7 @@ var Article = React__default['default'].memo(React.forwardRef(function (props, r
|
|
|
1170
1150
|
return React__default['default'].createElement(
|
|
1171
1151
|
'div',
|
|
1172
1152
|
null,
|
|
1173
|
-
useSegmentRecommendedArticles ? React__default['default'].createElement(Recommended, {
|
|
1153
|
+
useSegmentRecommendedArticles ? React__default['default'].createElement(Recommended, { client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default['default'].createElement(
|
|
1174
1154
|
'section',
|
|
1175
1155
|
{ id: 'related-content-section', className: 'my-1' },
|
|
1176
1156
|
(article.relatedArticle || RelevantTopics()) && React__default['default'].createElement(
|
|
@@ -1869,11 +1849,6 @@ var ArticleQueue = function ArticleQueue(props) {
|
|
|
1869
1849
|
active = _useState6[0],
|
|
1870
1850
|
setActive = _useState6[1];
|
|
1871
1851
|
|
|
1872
|
-
var _useState7 = React.useState(null),
|
|
1873
|
-
_useState8 = slicedToArray._slicedToArray(_useState7, 2),
|
|
1874
|
-
segmentData = _useState8[0],
|
|
1875
|
-
setSegmentData = _useState8[1];
|
|
1876
|
-
|
|
1877
1852
|
var refreshAD = function refreshAD(path) {
|
|
1878
1853
|
var activeArticle = queueData.find(function (item) {
|
|
1879
1854
|
return item.url.current === path;
|
|
@@ -2095,9 +2070,7 @@ var ArticleQueue = function ArticleQueue(props) {
|
|
|
2095
2070
|
// Passing queueData to check for single article
|
|
2096
2071
|
, queueData: queueData,
|
|
2097
2072
|
showRelatedArticles: showRelatedArticles,
|
|
2098
|
-
index: index
|
|
2099
|
-
segmentData: segmentData,
|
|
2100
|
-
setSegmentData: setSegmentData
|
|
2073
|
+
index: index
|
|
2101
2074
|
}))
|
|
2102
2075
|
);
|
|
2103
2076
|
})
|
package/dist/esm/View.js
CHANGED
|
@@ -450,9 +450,7 @@ var Recommended = function Recommended(props) {
|
|
|
450
450
|
client = props.client,
|
|
451
451
|
_props$index = props.index,
|
|
452
452
|
index = _props$index === undefined ? 0 : _props$index,
|
|
453
|
-
cpModificationRequired = props.cpModificationRequired
|
|
454
|
-
segmentData = props.segmentData,
|
|
455
|
-
setSegmentData = props.setSegmentData;
|
|
453
|
+
cpModificationRequired = props.cpModificationRequired;
|
|
456
454
|
|
|
457
455
|
var _useState = useState(false),
|
|
458
456
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -498,48 +496,29 @@ var Recommended = function Recommended(props) {
|
|
|
498
496
|
// get users traits
|
|
499
497
|
var getSegmentProfile = function () {
|
|
500
498
|
var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
501
|
-
var
|
|
499
|
+
var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
|
|
502
500
|
|
|
503
501
|
return regenerator.wrap(function _callee$(_context) {
|
|
504
502
|
while (1) {
|
|
505
503
|
switch (_context.prev = _context.next) {
|
|
506
504
|
case 0:
|
|
507
|
-
data = void 0;
|
|
508
|
-
|
|
509
|
-
if (segmentData) {
|
|
510
|
-
_context.next = 12;
|
|
511
|
-
break;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
505
|
anonymousId = analytics.user().anonymousId();
|
|
515
|
-
_context.next =
|
|
506
|
+
_context.next = 3;
|
|
516
507
|
return fetch('/api/getSegmentProfile', {
|
|
517
508
|
method: 'POST',
|
|
518
509
|
body: _JSON$stringify({ anonymousId: anonymousId })
|
|
519
510
|
});
|
|
520
511
|
|
|
521
|
-
case
|
|
512
|
+
case 3:
|
|
522
513
|
response = _context.sent;
|
|
523
|
-
_context.next =
|
|
514
|
+
_context.next = 6;
|
|
524
515
|
return response.json();
|
|
525
516
|
|
|
526
|
-
case
|
|
517
|
+
case 6:
|
|
527
518
|
data = _context.sent;
|
|
528
519
|
|
|
529
|
-
if (data && data.traits && data.traits.favorite_article_category) {
|
|
530
|
-
setSegmentData(data);
|
|
531
|
-
} else {
|
|
532
|
-
setLoaded('failed');
|
|
533
|
-
}
|
|
534
|
-
_context.next = 13;
|
|
535
|
-
break;
|
|
536
|
-
|
|
537
|
-
case 12:
|
|
538
|
-
data = segmentData;
|
|
539
|
-
|
|
540
|
-
case 13:
|
|
541
520
|
if (!(data && data.traits && data.traits.favorite_article_category)) {
|
|
542
|
-
_context.next =
|
|
521
|
+
_context.next = 24;
|
|
543
522
|
break;
|
|
544
523
|
}
|
|
545
524
|
|
|
@@ -570,10 +549,10 @@ var Recommended = function Recommended(props) {
|
|
|
570
549
|
params = {
|
|
571
550
|
id: article._id
|
|
572
551
|
};
|
|
573
|
-
_context.next =
|
|
552
|
+
_context.next = 16;
|
|
574
553
|
return _Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
|
|
575
554
|
|
|
576
|
-
case
|
|
555
|
+
case 16:
|
|
577
556
|
_ref2 = _context.sent;
|
|
578
557
|
_ref3 = _slicedToArray(_ref2, 3);
|
|
579
558
|
_articles = _ref3[0];
|
|
@@ -592,8 +571,13 @@ var Recommended = function Recommended(props) {
|
|
|
592
571
|
}
|
|
593
572
|
setArticles(_articles);
|
|
594
573
|
}
|
|
574
|
+
_context.next = 25;
|
|
575
|
+
break;
|
|
595
576
|
|
|
596
|
-
case
|
|
577
|
+
case 24:
|
|
578
|
+
setLoaded('failed');
|
|
579
|
+
|
|
580
|
+
case 25:
|
|
597
581
|
case 'end':
|
|
598
582
|
return _context.stop();
|
|
599
583
|
}
|
|
@@ -920,11 +904,7 @@ var Article = React__default.memo(forwardRef(function (props, ref) {
|
|
|
920
904
|
_props$downloadCitati = props.downloadCitation,
|
|
921
905
|
downloadCitation = _props$downloadCitati === undefined ? false : _props$downloadCitati,
|
|
922
906
|
_props$useSegmentReco = props.useSegmentRecommendedArticles,
|
|
923
|
-
useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco
|
|
924
|
-
_props$segmentData = props.segmentData,
|
|
925
|
-
segmentData = _props$segmentData === undefined ? null : _props$segmentData,
|
|
926
|
-
_props$setSegmentData = props.setSegmentData,
|
|
927
|
-
setSegmentData = _props$setSegmentData === undefined ? function () {} : _props$setSegmentData;
|
|
907
|
+
useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco;
|
|
928
908
|
var sliderData = props.sliderData;
|
|
929
909
|
|
|
930
910
|
|
|
@@ -1159,7 +1139,7 @@ var Article = React__default.memo(forwardRef(function (props, ref) {
|
|
|
1159
1139
|
return React__default.createElement(
|
|
1160
1140
|
'div',
|
|
1161
1141
|
null,
|
|
1162
|
-
useSegmentRecommendedArticles ? React__default.createElement(Recommended, {
|
|
1142
|
+
useSegmentRecommendedArticles ? React__default.createElement(Recommended, { client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default.createElement(
|
|
1163
1143
|
'section',
|
|
1164
1144
|
{ id: 'related-content-section', className: 'my-1' },
|
|
1165
1145
|
(article.relatedArticle || RelevantTopics()) && React__default.createElement(
|
|
@@ -1858,11 +1838,6 @@ var ArticleQueue = function ArticleQueue(props) {
|
|
|
1858
1838
|
active = _useState6[0],
|
|
1859
1839
|
setActive = _useState6[1];
|
|
1860
1840
|
|
|
1861
|
-
var _useState7 = useState(null),
|
|
1862
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
1863
|
-
segmentData = _useState8[0],
|
|
1864
|
-
setSegmentData = _useState8[1];
|
|
1865
|
-
|
|
1866
1841
|
var refreshAD = function refreshAD(path) {
|
|
1867
1842
|
var activeArticle = queueData.find(function (item) {
|
|
1868
1843
|
return item.url.current === path;
|
|
@@ -2084,9 +2059,7 @@ var ArticleQueue = function ArticleQueue(props) {
|
|
|
2084
2059
|
// Passing queueData to check for single article
|
|
2085
2060
|
, queueData: queueData,
|
|
2086
2061
|
showRelatedArticles: showRelatedArticles,
|
|
2087
|
-
index: index
|
|
2088
|
-
segmentData: segmentData,
|
|
2089
|
-
setSegmentData: setSegmentData
|
|
2062
|
+
index: index
|
|
2090
2063
|
}))
|
|
2091
2064
|
);
|
|
2092
2065
|
})
|