mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
clearCache each time version is outdated
This commit is contained in:
parent
6f12f26eb9
commit
d8d1a2409a
1 changed files with 7 additions and 5 deletions
|
|
@ -8,9 +8,12 @@ const version = "1.811"; // generator version, update each time
|
||||||
const loadingScreenVersion = document.getElementById("version");
|
const loadingScreenVersion = document.getElementById("version");
|
||||||
if (loadingScreenVersion) loadingScreenVersion.innerHTML = version;
|
if (loadingScreenVersion) loadingScreenVersion.innerHTML = version;
|
||||||
|
|
||||||
const majorChangesVersion = 1.811;
|
|
||||||
const storedVersion = +localStorage.getItem("version") || 0;
|
const storedVersion = +localStorage.getItem("version") || 0;
|
||||||
|
|
||||||
|
const isOutdated = storedVersion !== +version;
|
||||||
|
if (isOutdated) clearCache();
|
||||||
|
|
||||||
|
const majorChangesVersion = 1.811;
|
||||||
const showUpdate = storedVersion < majorChangesVersion;
|
const showUpdate = storedVersion < majorChangesVersion;
|
||||||
if (showUpdate) setTimeout(showUpdateWindow, 5000);
|
if (showUpdate) setTimeout(showUpdateWindow, 5000);
|
||||||
|
|
||||||
|
|
@ -42,14 +45,14 @@ const version = "1.811"; // generator version, update each time
|
||||||
const buttons = {
|
const buttons = {
|
||||||
Ok: function () {
|
Ok: function () {
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
if (storedVersion) clearStoredData();
|
if (storedVersion) localStorage.clear();
|
||||||
localStorage.setItem("version", version);
|
localStorage.setItem("version", version);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (storedVersion) {
|
if (storedVersion) {
|
||||||
buttons.Reload = () => {
|
buttons.Reload = () => {
|
||||||
clearStoredData();
|
localStorage.clear();
|
||||||
localStorage.setItem("version", version);
|
localStorage.setItem("version", version);
|
||||||
location.reload();
|
location.reload();
|
||||||
};
|
};
|
||||||
|
|
@ -64,8 +67,7 @@ const version = "1.811"; // generator version, update each time
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clearStoredData() {
|
async function clearCache() {
|
||||||
localStorage.clear();
|
|
||||||
const cacheNames = await caches.keys();
|
const cacheNames = await caches.keys();
|
||||||
Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
Promise.all(cacheNames.map(cacheName => caches.delete(cacheName)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue