mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 10:31:24 +01:00
fix the isOutdated function for versions past 1.99
This commit is contained in:
parent
8dd4d486f0
commit
6000f82ac9
3 changed files with 64 additions and 43 deletions
|
|
@ -8,11 +8,8 @@ const version = "1.100.00"; // generator version, update each time
|
|||
const loadingScreenVersion = document.getElementById("versionText");
|
||||
if (loadingScreenVersion) loadingScreenVersion.innerText = `v${version}`;
|
||||
|
||||
const versionNumber = parseFloat(version);
|
||||
const storedVersion = localStorage.getItem("version") ? parseFloat(localStorage.getItem("version")) : 0;
|
||||
|
||||
const isOutdated = storedVersion !== versionNumber;
|
||||
if (isOutdated) clearCache();
|
||||
const storedVersion = localStorage.getItem("version");
|
||||
if (isOutdated(storedVersion)) await clearCache();
|
||||
|
||||
const showUpdate = storedVersion < versionNumber;
|
||||
if (showUpdate) setTimeout(showUpdateWindow, 6000);
|
||||
|
|
@ -73,8 +70,15 @@ const version = "1.100.00"; // generator version, update each time
|
|||
});
|
||||
}
|
||||
|
||||
function isOutdated(storedVersion) {
|
||||
if (!storedVersion) return true;
|
||||
const [major, minor, _patch] = version.split(".");
|
||||
const [storedMajor, storedMinor, _storedPatch] = storedVersion.split(".");
|
||||
return storedMajor !== major || storedMinor !== minor; // ignore patch version
|
||||
}
|
||||
|
||||
async function clearCache() {
|
||||
const cacheNames = await caches.keys();
|
||||
Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
||||
return Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue