@mjhls/mjh-framework 1.0.939-segment-test-v10 → 1.0.939-segment-test-v12

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 CHANGED
@@ -507,7 +507,7 @@ var Recommended = function Recommended(props) {
507
507
  // get users traits
508
508
  var getSegmentProfile = function () {
509
509
  var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
510
- var anonymousId, response, data, addTaxonomyName, fetchWithTimeout, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
510
+ var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
511
511
 
512
512
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
513
513
  while (1) {
@@ -529,7 +529,7 @@ var Recommended = function Recommended(props) {
529
529
  data = _context.sent;
530
530
 
531
531
  if (!(data && data.traits && data.traits.favorite_article_category)) {
532
- _context.next = 26;
532
+ _context.next = 40;
533
533
  break;
534
534
  }
535
535
 
@@ -551,40 +551,52 @@ var Recommended = function Recommended(props) {
551
551
  return query;
552
552
  };
553
553
 
554
- fetchWithTimeout = function fetchWithTimeout(timeout, fn) {
555
-
556
- return new asyncToGenerator._Promise(function (resolve, reject) {
557
- // start timeout
558
- var timeoutID = setTimeout(function () {
559
- return resolve([]);
560
- }, timeout);
561
- // start calculation
562
- fn().then(function (result) {
563
- clearTimeout(timeoutID);
564
- resolve(result);
565
- });
566
- });
567
- };
568
-
569
554
  favoriteCategories = JSON.parse(data.traits.favorite_article_category);
570
- // grab 3 articles from sanity different from the one currently being read
571
555
 
572
- articlesQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Articles\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 5) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
573
- videosQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Videos\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ' ]._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 1) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
574
- podcastQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Podcasts\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 2) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
556
+ //grab contentCategory ID
557
+
558
+ _context.next = 12;
559
+ return client.fetch("*[_type == 'contentCategory' && name == 'Articles'][0]{_id}");
560
+
561
+ case 12:
562
+ articlesCategory = _context.sent;
563
+ _context.next = 15;
564
+ return client.fetch("*[_type == 'contentCategory' && name == 'Videos'][0]{_id}");
565
+
566
+ case 15:
567
+ videosCategory = _context.sent;
568
+ _context.next = 18;
569
+ return client.fetch("*[_type == 'contentCategory' && name == 'Podcasts'][0]{_id}");
570
+
571
+ case 18:
572
+ podcastCategory = _context.sent;
573
+ _context.next = 21;
574
+ return client.fetch('*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']');
575
+
576
+ case 21:
577
+ taxonomyCategories = _context.sent;
578
+ taxonomies = '';
579
+
580
+ taxonomyCategories.forEach(function (taxonomy, index) {
581
+ if (index === 0) {
582
+ taxonomies = taxonomies + (' && ( references(\'' + taxonomy._id + '\')');
583
+ } else {
584
+ taxonomies = taxonomies + (' || references(\'' + taxonomy._id + '\')');
585
+ }
586
+ });
587
+ taxonomies = taxonomies + ' )';
588
+
589
+ // grab 3 articles from sanity different from the one currently being read
590
+ articlesQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + articlesCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 5) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
591
+ videosQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + videosCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 1) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
592
+ podcastQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + podcastCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 2) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
575
593
  params = {
576
594
  id: article._id
577
595
  };
578
- _context.next = 17;
579
- return asyncToGenerator._Promise.all([fetchWithTimeout(3000, function () {
580
- return client.fetch(articlesQuery, params);
581
- }), fetchWithTimeout(2000, function () {
582
- return client.fetch(videosQuery, params);
583
- }), fetchWithTimeout(2000, function () {
584
- return client.fetch(podcastQuery, params);
585
- })]);
586
-
587
- case 17:
596
+ _context.next = 31;
597
+ return asyncToGenerator._Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
598
+
599
+ case 31:
588
600
  _ref2 = _context.sent;
589
601
  _ref3 = slicedToArray._slicedToArray(_ref2, 3);
590
602
  _articles = _ref3[0];
@@ -604,13 +616,13 @@ var Recommended = function Recommended(props) {
604
616
  }
605
617
  setArticles(_articles);
606
618
  }
607
- _context.next = 27;
619
+ _context.next = 41;
608
620
  break;
609
621
 
610
- case 26:
622
+ case 40:
611
623
  setLoaded('failed');
612
624
 
613
- case 27:
625
+ case 41:
614
626
  case 'end':
615
627
  return _context.stop();
616
628
  }
package/dist/esm/View.js CHANGED
@@ -496,7 +496,7 @@ var Recommended = function Recommended(props) {
496
496
  // get users traits
497
497
  var getSegmentProfile = function () {
498
498
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
499
- var anonymousId, response, data, addTaxonomyName, fetchWithTimeout, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
499
+ var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
500
500
 
501
501
  return regenerator.wrap(function _callee$(_context) {
502
502
  while (1) {
@@ -518,7 +518,7 @@ var Recommended = function Recommended(props) {
518
518
  data = _context.sent;
519
519
 
520
520
  if (!(data && data.traits && data.traits.favorite_article_category)) {
521
- _context.next = 26;
521
+ _context.next = 40;
522
522
  break;
523
523
  }
524
524
 
@@ -540,40 +540,52 @@ var Recommended = function Recommended(props) {
540
540
  return query;
541
541
  };
542
542
 
543
- fetchWithTimeout = function fetchWithTimeout(timeout, fn) {
544
-
545
- return new _Promise(function (resolve, reject) {
546
- // start timeout
547
- var timeoutID = setTimeout(function () {
548
- return resolve([]);
549
- }, timeout);
550
- // start calculation
551
- fn().then(function (result) {
552
- clearTimeout(timeoutID);
553
- resolve(result);
554
- });
555
- });
556
- };
557
-
558
543
  favoriteCategories = JSON.parse(data.traits.favorite_article_category);
559
- // grab 3 articles from sanity different from the one currently being read
560
544
 
561
- articlesQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Articles\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 5) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
562
- videosQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Videos\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ' ]._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 1) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
563
- podcastQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(*[_type == \'contentCategory\' && name == \'Podcasts\']._id)\n && references(*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']._id)\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 2) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
545
+ //grab contentCategory ID
546
+
547
+ _context.next = 12;
548
+ return client.fetch("*[_type == 'contentCategory' && name == 'Articles'][0]{_id}");
549
+
550
+ case 12:
551
+ articlesCategory = _context.sent;
552
+ _context.next = 15;
553
+ return client.fetch("*[_type == 'contentCategory' && name == 'Videos'][0]{_id}");
554
+
555
+ case 15:
556
+ videosCategory = _context.sent;
557
+ _context.next = 18;
558
+ return client.fetch("*[_type == 'contentCategory' && name == 'Podcasts'][0]{_id}");
559
+
560
+ case 18:
561
+ podcastCategory = _context.sent;
562
+ _context.next = 21;
563
+ return client.fetch('*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']');
564
+
565
+ case 21:
566
+ taxonomyCategories = _context.sent;
567
+ taxonomies = '';
568
+
569
+ taxonomyCategories.forEach(function (taxonomy, index) {
570
+ if (index === 0) {
571
+ taxonomies = taxonomies + (' && ( references(\'' + taxonomy._id + '\')');
572
+ } else {
573
+ taxonomies = taxonomies + (' || references(\'' + taxonomy._id + '\')');
574
+ }
575
+ });
576
+ taxonomies = taxonomies + ' )';
577
+
578
+ // grab 3 articles from sanity different from the one currently being read
579
+ articlesQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + articlesCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 5) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
580
+ videosQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + videosCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 1) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
581
+ podcastQuery = '*[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && is_visible == true \n && passwordLock != true\n && references(\'' + podcastCategory._id + '\')\n ' + taxonomies + '\n && defined(published)\n && _id != $id\n && dateTime(published) <= dateTime(now())] | order(published desc) [' + starting + '...' + (starting + 2) + '] {\n ...,\n title,\n thumbnail,\n url,\n contentCategory->,\n published,\n }';
564
582
  params = {
565
583
  id: article._id
566
584
  };
567
- _context.next = 17;
568
- return _Promise.all([fetchWithTimeout(3000, function () {
569
- return client.fetch(articlesQuery, params);
570
- }), fetchWithTimeout(2000, function () {
571
- return client.fetch(videosQuery, params);
572
- }), fetchWithTimeout(2000, function () {
573
- return client.fetch(podcastQuery, params);
574
- })]);
575
-
576
- case 17:
585
+ _context.next = 31;
586
+ return _Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
587
+
588
+ case 31:
577
589
  _ref2 = _context.sent;
578
590
  _ref3 = _slicedToArray(_ref2, 3);
579
591
  _articles = _ref3[0];
@@ -593,13 +605,13 @@ var Recommended = function Recommended(props) {
593
605
  }
594
606
  setArticles(_articles);
595
607
  }
596
- _context.next = 27;
608
+ _context.next = 41;
597
609
  break;
598
610
 
599
- case 26:
611
+ case 40:
600
612
  setLoaded('failed');
601
613
 
602
- case 27:
614
+ case 41:
603
615
  case 'end':
604
616
  return _context.stop();
605
617
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.939-segment-test-v10",
3
+ "version": "1.0.939-segment-test-v12",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",