mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 18:41:23 +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}`;
|
if (loadingScreenVersion) loadingScreenVersion.innerText = `v${version}`;
|
||||||
|
|
||||||
const storedVersion = localStorage.getItem("version");
|
const storedVersion = localStorage.getItem("version");
|
||||||
if (compareVersions(storedVersion, version).isOlder) {
|
if (compareVersions(storedVersion, version).isOlder) setTimeout(showUpdateWindow, 6000);
|
||||||
await clearCache();
|
|
||||||
setTimeout(showUpdateWindow, 6000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showUpdateWindow() {
|
function showUpdateWindow() {
|
||||||
const changelog = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog";
|
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 = {
|
const buttons = {
|
||||||
Ok: function () {
|
Ok: function () {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
if (storedVersion) localStorage.clear();
|
if (storedVersion) {
|
||||||
|
clearCache();
|
||||||
|
localStorage.clear();
|
||||||
|
}
|
||||||
localStorage.setItem("version", version);
|
localStorage.setItem("version", version);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (storedVersion) {
|
if (storedVersion) {
|
||||||
buttons.Reload = () => {
|
buttons.Reload = () => {
|
||||||
|
clearCache();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
localStorage.setItem("version", version);
|
localStorage.setItem("version", version);
|
||||||
location.reload();
|
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() {
|
async function clearCache() {
|
||||||
const cacheNames = await caches.keys();
|
const cacheNames = await caches.keys();
|
||||||
return 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