added automatic client page reload (#3188)

solution for #3105 

~~not sure if updatenotification is the right place, so opinions?~~

now impleneted in `main.js`
This commit is contained in:
Karsten Hassel
2023-09-13 22:46:17 +02:00
committed by GitHub
parent f2957f90df
commit 7a1591b2d6
5 changed files with 41 additions and 2 deletions

View File

@@ -568,12 +568,33 @@ const MM = (function () {
*/
modulesStarted: function (moduleObjects) {
modules = [];
let startUp = "";
moduleObjects.forEach((module) => modules.push(module));
Log.info("All modules started!");
sendNotification("ALL_MODULES_STARTED");
createDomObjects();
if (config.reloadAfterServerRestart) {
setInterval(async () => {
// if server startup time has changed (which means server was restarted)
// the client reloads the mm page
try {
const res = await fetch(`${location.protocol}//${location.host}/startup`);
const curr = await res.text();
if (startUp === "") startUp = curr;
if (startUp !== curr) {
startUp = "";
window.location.reload(true);
console.warn("Refreshing Website because server was restarted");
}
} catch (err) {
Log.error(`MagicMirror not reachable: ${err}`);
}
}, config.checkServerInterval);
}
},
/**