Closed WKFO closed 1 year ago
This is cumbersome.
As you can see, we store the variable refresh
(bool) in the local storage to check if the page is refreshed or not. So it is set to true
when the page gets unloaded. The problem is it always stays as true
for the next visits of the landing page.
It is set to false
after a "refresh" message is shown but I assume it is not working.
Any ideas @Cthulhu2?
sessionStorage
does what you want.if (sessionStorage.getItem("refresh") === "true") {
sessionStorage.setItem("refresh", false);
setRandomMsg(getRandomFromArray(REFRESH_MESSAGES));
}
...
window.onbeforeunload = function () {
sessionStorage.setItem("refresh", true);
return;
}
PerformanceNavigationTiming.type
property with reload
value in the Performance API
. May be it is more standard way.performance.getEntriesByType("navigation").forEach((entry) => {
if (entry.type === "reload") {
setRandomMsg(getRandomFromArray(REFRESH_MESSAGES));
}
});
Oh yeah, using sessionStorage
definitely makes sense. I haven't heard about using the 2nd option.
Do you mind going ahead and creating a PR or should I do it?
In Firefox 110.0, the first time you enter CMF, it shows a page refresh message on the button, not a first time welcome message.