web-manager 3.2.42 → 3.2.44

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.
Files changed (3) hide show
  1. package/index.js +19 -5
  2. package/lib/account.js +20 -9
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -87,6 +87,7 @@ function Manager() {
87
87
  global: {
88
88
  version: '',
89
89
  url: '',
90
+ buildTime: 0,
90
91
  cacheBreaker: '',
91
92
  brand: {
92
93
  name: 'default'
@@ -555,6 +556,7 @@ function Manager() {
555
556
  self.properties.global.app = configuration.global.app;
556
557
  self.properties.global.version = configuration.global.version;
557
558
  self.properties.global.url = configuration.global.url;
559
+ self.properties.global.buildTime = new Date((+configuration.global.buildTime * 1000) || new Date())
558
560
  self.properties.global.cacheBreaker = configuration.global.cacheBreaker;
559
561
 
560
562
  self.properties.global.brand = configuration.global.brand;
@@ -1192,7 +1194,8 @@ function Manager() {
1192
1194
  function refreshNewVersion(self) {
1193
1195
  console.log('refreshNewVersion()');
1194
1196
 
1195
- fetch('/@output/build/build.json' + '?cb=' + new Date().getTime())
1197
+ // Make request to get the build time (live)
1198
+ fetch('/@output/build/build.json?cb=' + new Date().getTime())
1196
1199
  .then(function (res) {
1197
1200
  if (res.ok) {
1198
1201
  return res.json();
@@ -1201,15 +1204,26 @@ function Manager() {
1201
1204
  }
1202
1205
  })
1203
1206
  .then(function (data) {
1204
- var buildTime = new Date(data['npm-build'].timestamp_utc);
1205
- var startTime = self.properties.page.startTime;
1207
+ var buildTimeCurrent = self.properties.global.buildTime || new Date(0);
1208
+ var buildTimeLive = new Date(data['npm-build'].timestamp);
1206
1209
 
1207
- if (buildTime > startTime) {
1208
- // console.log('refreshNewVersion(): Refreshing...');
1210
+ // Log
1211
+ console.log('refreshNewVersion()', data, buildTimeCurrent, buildTimeLive);
1209
1212
 
1213
+ // If the live time is newer, refresh
1214
+ if (buildTimeCurrent < buildTimeLive) {
1215
+ console.log('refreshNewVersion(): Refreshing...');
1216
+
1217
+ if (self.isDevelopment()) {
1218
+ return;
1219
+ }
1220
+
1221
+ // Force page reload
1210
1222
  window.onbeforeunload = function () {
1211
1223
  return undefined;
1212
1224
  }
1225
+
1226
+ // Refresh
1213
1227
  window.location.reload(true);
1214
1228
  }
1215
1229
  })
package/lib/account.js CHANGED
@@ -266,15 +266,21 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
266
266
  account.plan.trial.expires.timestampUNIX = Math.round(new Date(account.plan.trial.expires.timestamp || 0).getTime() / 1000);
267
267
 
268
268
  // @@@DEVELOPER
269
+ // var date = '2024-04-23T00:07:29.183Z';
270
+ // var date = `2024-03-23T00:07:29.183Z`;
269
271
  // account.plan.id = 'basic';
270
272
  // account.plan.trial = {
271
273
  // activated: false,
272
274
  // expires: {
273
- // timestamp: new Date('2024-04-23T00:07:29.183Z').toISOString(),
274
- // timestampUNIX: Math.round(new Date('2024-04-23T00:07:29.183Z').getTime() / 1000),
275
- // }
275
+ // timestamp: new Date(date).toISOString(),
276
+ // timestampUNIX: Math.round(new Date(date).getTime() / 1000),
277
+ // },
276
278
  // }
277
- // account.plan.status = 'suspended';
279
+ // account.plan.expires = {
280
+ // timestamp: new Date(date).toISOString(),
281
+ // timestampUNIX: Math.round(new Date(date).getTime() / 1000),
282
+ // }
283
+ // account.plan.status = 'cancelled';
278
284
 
279
285
  account.plan.limits = account.plan.limits || {};
280
286
  // account.plan.devices = account.plan.devices || 1;
@@ -329,6 +335,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
329
335
  var trialExpireDate = new Date(account.plan.trial.expires.timestamp);
330
336
  var daysTillTrialExpire = Math.floor((trialExpireDate - now) / 86400000);
331
337
  var startDate = new Date(account.plan.payment.startDate.timestamp);
338
+ var unresolvedPlanId = account.plan.id;
332
339
  var planIsActive = difference > -1 && account.plan.id !== defaultPlanId;
333
340
  var planIsSuspended = account.plan.status === 'suspended';
334
341
 
@@ -511,13 +518,15 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
511
518
  // If user is on trial, start date is trial exp date
512
519
  var visibleStartDate = account.plan.trial.activated ? account.plan.trial.expires.timestamp : account.plan.payment.startDate.timestamp;
513
520
  // If basic, just show account creation date
514
- if (isBasicPlan) {
521
+ if (unresolvedPlanId === defaultPlanId) {
515
522
  visibleStartDate = accountCreationDate;
523
+ billingStatusEl.setAttribute('hidden', true);
516
524
  }
517
525
  var visibleFrequency = account.plan.payment.frequency === 'unknown' ? 'monthly' : account.plan.payment.frequency;
518
526
 
519
527
  // Update billing UI
520
- billingPlanId.setInnerHTML(splitDashesAndUppercase(account.plan.id));
528
+ // billingPlanId.setInnerHTML(splitDashesAndUppercase(account.plan.id));
529
+ billingPlanId.setInnerHTML(splitDashesAndUppercase(unresolvedPlanId)); // Show unresolved because we want to show what plan they have bought not what the expirattion status resolves to
521
530
  billingFrequencyEl.setInnerHTML(visibleFrequency);
522
531
  billingStatusEl.setInnerHTML(visibleStatus);
523
532
  billingStatusColorEl
@@ -531,9 +540,11 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
531
540
  billingStartDateEl.setInnerHTML(new Date(visibleStartDate).toLocaleString(undefined, {
532
541
  year: 'numeric', month: 'long', day: 'numeric',
533
542
  }));
534
- billingExpirationDateEl.setInnerHTML(isBasicPlan && daysTillExpire < 366
535
- ? '<i class="fas fa-exclamation-triangle mr-1"></i> Expires in ' + daysTillExpire + ' days '
536
- : '');
543
+ // billingExpirationDateEl.setInnerHTML(isBasicPlan && daysTillExpire < 366
544
+ billingExpirationDateEl.setInnerHTML('<i class="fas fa-exclamation-triangle mr-1"></i> Expires in ' + daysTillExpire + ' days ');
545
+ if (daysTillExpire > 0 && daysTillExpire < 366) {
546
+ billingExpirationDateEl.removeAttribute('hidden');
547
+ }
537
548
 
538
549
  // Update payment method UI
539
550
  if (account.plan.status === 'suspended') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.42",
3
+ "version": "3.2.44",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {