Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit 3c64034

Browse files
authored
Merge pull request #247 from FIRST-Tech-Challenge/pr_issue_240
Do reload if user hits back button
2 parents 07ca935 + 013882a commit 3c64034

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

server/src/js/util.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ goog.provide('fmltc.Util');
2727
* @constructor
2828
*/
2929
fmltc.Util = function(pageBasename, preferences, limitData, modelTrainerData, trainingEnabled) {
30+
window.addEventListener('pageshow', function(event) {
31+
// event.persisted means the page is loading from a cache.
32+
var needToReload = false;
33+
if (event.persisted) {
34+
needToReload = true;
35+
} else {
36+
// Check if we got to this page from the back (or forward) button.
37+
var perfEntries = performance.getEntriesByType('navigation');
38+
if (perfEntries.length > 0 && perfEntries[0].type === 'back_forward') {
39+
needToReload = true;
40+
}
41+
}
42+
if (needToReload) {
43+
location.reload();
44+
}
45+
});
46+
3047
this.pageBasename = pageBasename;
3148
this.preferences = preferences;
3249
this.limitData = limitData;

0 commit comments

Comments
 (0)