@nuskin/ns-shop 7.0.5-cx1-13272.8 → 7.0.5-cx1-13272.10

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.8",
3
+ "version": "7.0.5-cx1-13272.10",
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": {
@@ -162,59 +162,9 @@ async function getEventStatus(eventsToCheck = []) {
162
162
  eventStatus[eventName] = activeStatus;
163
163
  });
164
164
 
165
- // responses.forEach((response) => {
166
- // let activeStatus = false;
167
- // if (response.status === 'fulfilled' && response.value) {
168
- // const status = _decodeStatus(response.value.status);
169
- // if ((status.eventStatus === PRE_EVENT && status.preWaitTime <= 30000) ||
170
- // status.eventStatus === IN_EVENT) {
171
- // activeStatus = true;
172
- // }
173
- // eventStatus[response.value.eventName] = activeStatus;
174
- // }
175
- // });
176
-
177
165
  return eventStatus;
178
166
  }
179
167
 
180
- /**
181
- * Either requests a new ticket or an updated event ticket from the AWS service
182
- *
183
- * @param eventTicketInfo - contains informatino about the ticket.
184
- *
185
- * @returns {Promise<*>} a new or updated ticket for the specified event
186
- * @private
187
- */
188
- // async function _getTempTicket(eventName, externalId) {
189
- // let ticket;
190
-
191
- // try {
192
- // let method = 'POST',
193
- // seParams = _getSeParams(eventName, false),
194
- // response = await axios({
195
- // method: method,
196
- // url: `${_getAwsUrl(eventName, null)}?orderEventCheck=${externalId}${seParams}`,
197
- // headers: _getHeaders(),
198
- // timeout: 7000
199
- // });
200
-
201
- // ticket = response.data.salesEventResponse;
202
- // } catch (err) {
203
- // if (err.response && err.response.data.status === 404) {
204
- // console.error(`getTempTicket - unable to get a temporary ticket for ${eventName}`);
205
- // throw err;
206
- // } else {
207
- // console.error(`getTempTicket error or timeout - waiting to try again for ${eventName}`);
208
- // // Timed out or some other error
209
- // // Wait and then call again.
210
- // await _wait(3000);
211
- // ticket = await _getTempTicket(eventName);
212
- // }
213
- // }
214
-
215
- // return ticket;
216
- // }
217
-
218
168
  function logAnalyticInfo(tag, eventName, data = {}) {
219
169
  const user = UserService.getUser();
220
170
  const eventTicketInfo = eventTicketInfoMap[eventName];
@@ -255,6 +205,8 @@ function logAnalyticInfo(tag, eventName, data = {}) {
255
205
  */
256
206
  let initEventTicketCallMap = {};
257
207
  async function _initEventTicketInfo(eventName, refreshTicket = false) {
208
+ myAlert(`_initEventTicketInfo, ${eventName}`);
209
+
258
210
  let initInfo = initEventTicketCallMap[eventName];
259
211
  if (!initInfo) {
260
212
  initInfo = {initialized: false, refreshTime: 0};
@@ -832,12 +784,20 @@ async function _checkForMissingTicket(eventName) {
832
784
  }
833
785
  }
834
786
 
787
+ function myAlert(msg) {
788
+ if (window.ReactNativeWebView) {
789
+ alert(msg);
790
+ }
791
+ }
792
+
835
793
  /**
836
794
  * This initializes an interval timer which checks to see if the browser (computer)
837
795
  * went to sleep. It's intention is to update the wait timer if it has.
838
796
  */
839
797
  async function _initializePolling() {
798
+ myAlert('_initializePolling');
840
799
  if (!intervalId) {
800
+ myAlert('_initializePolling - no intervalId');
841
801
  const TIMEOUT = 10000;
842
802
  let lastTime = Date.now(),
843
803
  intervalCnt = 1;
@@ -846,6 +806,8 @@ async function _initializePolling() {
846
806
  const now = Date.now();
847
807
  const slept = now > (lastTime + TIMEOUT + 3000)
848
808
 
809
+ myAlert('polling triggered');
810
+
849
811
  // if polling market config, only reload it every 30 seconds
850
812
  if (slept || pollMarketConfig && intervalCnt % 6 === 0) {
851
813
  await _loadMarketEventConfig(true);
@@ -867,10 +829,12 @@ async function _initializePolling() {
867
829
  _checkStatus(eventTicketInfo, false);
868
830
  });
869
831
 
870
- // check for missing tickets
871
- const activeEvents = await _getActiveEvents();
872
- for (const eventInfo of activeEvents) {
873
- await _checkForMissingTicket(eventInfo.eventName);
832
+ if (window.location.pathname === '/static/checkout/checkout.html') {
833
+ // check for missing tickets. Only perform on checkout s
834
+ const activeEvents = await _getActiveEvents();
835
+ for (const eventInfo of activeEvents) {
836
+ await _checkForMissingTicket(eventInfo.eventName);
837
+ }
874
838
  }
875
839
 
876
840
  lastTime = now;
@@ -1066,12 +1030,15 @@ async function initActiveEvents(country = undefined) {
1066
1030
  }
1067
1031
 
1068
1032
  return Promise.all(promises).then(async () => {
1033
+ myAlert(`Initial Events, ${[Object.keys(activeEventMap)]}`);
1034
+
1069
1035
  events.setValue(events.salesevent.INITIAL_ACTIVE_EVENTS, [Object.keys(activeEventMap)]);
1070
1036
 
1071
1037
  // If there are event tickets then initialize polling
1072
- if (Object.keys(eventTicketInfoMap).length > 0 && !country) {
1073
- await _initializePolling();
1074
- }
1038
+ // if (Object.keys(eventTicketInfoMap).length > 0 && !country) {
1039
+ // Test
1040
+ await _initializePolling();
1041
+ // }
1075
1042
  _removeWaitCheck(INITIALIZING);
1076
1043
  });
1077
1044
  }
@@ -1127,13 +1094,13 @@ async function _init(force = true) {
1127
1094
  * If there are, make sure polling is happening, otherwise, stop polling.
1128
1095
  */
1129
1096
  events.subscribe(events.salesevent.ACTIVE_EVENTS, (/*activeEvents*/) => {
1130
- if (eventTicketInfoMap) {
1131
- if (Object.keys(eventTicketInfoMap).length > 0) {
1132
- _initializePolling().then(() => console.log('Polling initialized'));
1133
- } else {
1134
- _clearPollingInterval();
1135
- }
1136
- }
1097
+ // if (eventTicketInfoMap) {
1098
+ // if (Object.keys(eventTicketInfoMap).length > 0) {
1099
+ _initializePolling().then(() => console.log('Polling initialized'));
1100
+ // } else {
1101
+ // _clearPollingInterval();
1102
+ // }
1103
+ // }
1137
1104
  });
1138
1105
 
1139
1106
  // persistentCartService needs to wait until the following configMaps are loaded