web-manager 3.2.42 → 3.2.43

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 (2) hide show
  1. package/index.js +15 -5
  2. 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);
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,22 @@ 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;
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
+ // Force page reload
1210
1218
  window.onbeforeunload = function () {
1211
1219
  return undefined;
1212
1220
  }
1221
+
1222
+ // Refresh
1213
1223
  window.location.reload(true);
1214
1224
  }
1215
1225
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.42",
3
+ "version": "3.2.43",
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": {