From 8043bcc3fae3c7300c1fa85b0dd5cf1f05b290a9 Mon Sep 17 00:00:00 2001 From: Martin Benjamins Date: Sun, 10 Sep 2023 03:56:19 +0200 Subject: [PATCH] Add force update check --- wwwroot/js/main.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wwwroot/js/main.js b/wwwroot/js/main.js index 0038647..35165be 100644 --- a/wwwroot/js/main.js +++ b/wwwroot/js/main.js @@ -40,8 +40,8 @@ $(function() { checkForUpdates(); }); -async function checkForUpdates() { - if (document.cookie) { +async function checkForUpdates(force = false) { + if (document.cookie && !force) { newUpdateAvailable(JSON.parse(document.cookie).updateAvailable); return; } @@ -73,13 +73,19 @@ function newUpdateAvailable(isUpdateAvailable) { var updateDiv = document.createElement("div"); updateDiv.id = 'updateDiv'; if (isUpdateAvailable) { - updateDiv.innerHTML = " An update to version " + JSON.parse(document.cookie).latestVersion + " is available!"; + updateDiv.innerHTML = " An update to version " + JSON.parse(document.cookie).latestVersion + " is available! "; } else { - updateDiv.innerHTML = " Up to date."; + updateDiv.innerHTML = " Up to date. "; } navBar[0].appendChild(updateDiv); } +function forceUpdateCheck() { + var element = document.getElementById("updateDiv"); + element.parentNode.removeChild(element); + checkForUpdates(true); +} + function renderBLPToIMGElement(url, elementID){ fetch(url).then(function(response) { return response.arrayBuffer();