From bfddccddec42c70a428f7405e23af413b48ee327 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Wed, 8 May 2024 07:49:28 +1000 Subject: [PATCH] =?UTF-8?q?Work=20on=20settings=20#655=20=F0=9F=94=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/js/common.js | 16 ++++++++++++++++ front/settings.php | 15 +++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/front/js/common.js b/front/js/common.js index 70f9ec56..7fbb99e6 100755 --- a/front/js/common.js +++ b/front/js/common.js @@ -563,6 +563,22 @@ function debugTimer () { $('#pageTitle').html (new Date().getSeconds()); } +// ----------------------------------------------------------------------------- +function secondsSincePageLoad() { + // Get the current time + var currentTime = Date.now(); + + // Get the time when the page was loaded + var pageLoadTime = performance.timeOrigin; + + // Calculate the difference in milliseconds + var timeDifference = currentTime - pageLoadTime; + + // Convert milliseconds to seconds + var secondsAgo = Math.floor(timeDifference / 1000); + + return secondsAgo; +} // ----------------------------------------------------------------------------- // Open url in new tab diff --git a/front/settings.php b/front/settings.php index 332eff15..2abd6ea6 100755 --- a/front/settings.php +++ b/front/settings.php @@ -813,27 +813,34 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { fileModificationTime = ; - console.log(appState["settingsImported"]*1000) + // console.log(appState["settingsImported"]*1000) importedMiliseconds = parseInt((appState["settingsImported"]*1000)); humanReadable = (new Date(importedMiliseconds)).toLocaleString("en-UK", { timeZone: "" }); - console.log(humanReadable.replaceAll('"', '')) + // console.log(humanReadable.replaceAll('"', '')) // check if displayed settings are outdated - // if(fileModificationTime > importedMiliseconds) + if(appState["showSpinner"] || fileModificationTime > importedMiliseconds) { + showSpinner("settings_old") setTimeout("handleLoadingDialog()", 1000); } else { - // chekc if the app is initialized and hide the spinner + // check if the app is initialized and hide the spinner if(isAppInitialized()) { hideSpinner() + + // reload page if outdated information might be displayed + if(secondsSincePageLoad() > 3) + { + clearCache() + } } else {