mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 10:31:24 +01:00
feat: improve version detection and update process
This commit is contained in:
parent
94acbdae65
commit
5fd55f3f9c
1 changed files with 6 additions and 12 deletions
|
|
@ -9,10 +9,7 @@ const version = "1.100.00"; // generator version, update each time
|
|||
if (loadingScreenVersion) loadingScreenVersion.innerText = `v${version}`;
|
||||
|
||||
const storedVersion = localStorage.getItem("version");
|
||||
if (compareVersions(storedVersion, version).isOlder) {
|
||||
await clearCache();
|
||||
setTimeout(showUpdateWindow, 6000);
|
||||
}
|
||||
if (compareVersions(storedVersion, version).isOlder) setTimeout(showUpdateWindow, 6000);
|
||||
|
||||
function showUpdateWindow() {
|
||||
const changelog = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog";
|
||||
|
|
@ -48,13 +45,17 @@ const version = "1.100.00"; // generator version, update each time
|
|||
const buttons = {
|
||||
Ok: function () {
|
||||
$(this).dialog("close");
|
||||
if (storedVersion) localStorage.clear();
|
||||
if (storedVersion) {
|
||||
clearCache();
|
||||
localStorage.clear();
|
||||
}
|
||||
localStorage.setItem("version", version);
|
||||
}
|
||||
};
|
||||
|
||||
if (storedVersion) {
|
||||
buttons.Reload = () => {
|
||||
clearCache();
|
||||
localStorage.clear();
|
||||
localStorage.setItem("version", version);
|
||||
location.reload();
|
||||
|
|
@ -70,13 +71,6 @@ 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();
|
||||
return Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue