web-manager 3.2.42 → 3.2.43
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +15 -5
- 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
|
-
|
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
|
1205
|
-
var
|
1207
|
+
var buildTimeCurrent = self.properties.global.buildTime;
|
1208
|
+
var buildTimeLive = new Date(data['npm-build'].timestamp);
|
1206
1209
|
|
1207
|
-
|
1208
|
-
|
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