@nuskin/ns-shop 7.0.5-cx1-13272.2 → 7.0.5-cx1-13272.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-shop",
3
- "version": "7.0.5-cx1-13272.2",
3
+ "version": "7.0.5-cx1-13272.3",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
@@ -686,6 +686,15 @@ function _getHeaders() {
686
686
  };
687
687
  }
688
688
 
689
+ async function _getActiveEvents() {
690
+ let response = await axios({
691
+ method: 'GET',
692
+ url: `${_getAwsUrl()}?activeWithin=${ACTIVE_EVENT_WITHIN}`,
693
+ headers: _getHeaders()
694
+ });
695
+ return response.data.salesEventResponse
696
+ }
697
+
689
698
  //=========================================================================================================//
690
699
  //
691
700
  // Misc functions
@@ -828,7 +837,6 @@ async function _initializePolling() {
828
837
  // if been to sleep for more then 3 seconds then check all ticket statuses.
829
838
  if (slept) {
830
839
  // Went to sleep for 3 seconds or more
831
-
832
840
  Object.values(eventTicketInfoMap).forEach(eventTicketInfo => {
833
841
  // A new timer needs to be set, clear current one if exists
834
842
  eventTicketInfo.needsStatusCheck = true;
@@ -841,13 +849,16 @@ async function _initializePolling() {
841
849
  });
842
850
 
843
851
  // check for missing tickets
844
- for (const eventName in Object.keys(mktEventConfigMap)) {
845
- if (!eventTicketInfoMap[eventName]) {
846
- await _initEventTicketInfo(eventName);
852
+ if (slept) {
853
+ const activeEvents = await _getActiveEvents();
854
+ for (const eventInfo of activeEvents) {
855
+ if (mktEventConfigMap[eventInfo.eventName] && !eventTicketInfoMap[eventInfo.eventName]) {
856
+ await _initEventTicketInfo(eventInfo.eventName);
857
+ }
847
858
  }
848
859
  }
849
860
 
850
- lastTime = now;
861
+ lastTime = Date.now();
851
862
  }, TIMEOUT);
852
863
  }
853
864
  }
@@ -998,12 +1009,7 @@ async function _loadAwsActiveEvents(country) {
998
1009
  storageObj = {events: []};
999
1010
  storage.setItem(activeEventsName, storageObj, {ttl: 250}); // to prevent multiple calls.
1000
1011
  try {
1001
- let response = await axios({
1002
- method: 'GET',
1003
- url: `${_getAwsUrl()}?activeWithin=${ACTIVE_EVENT_WITHIN}`,
1004
- headers: _getHeaders()
1005
- });
1006
- addEvents(response.data.salesEventResponse);
1012
+ addEvents(await _getActiveEvents());
1007
1013
  } catch (e) {
1008
1014
  // an error occurred with the call, clear active events
1009
1015
  // so it won't wait 30 minutes to try again