Add setting to manually clear the tile and geocode caches

This commit is contained in:
Skylar Ittner 2020-01-13 20:37:05 -07:00
parent 410a410d35
commit 50321d2bdc
3 changed files with 33 additions and 6 deletions

View File

@ -20,16 +20,29 @@ function logout() {
function resyncAndRestart() { function resyncAndRestart() {
app.toast.show({ app.toast.show({
text: "Syncing settings and restarting...", text: "Syncing settings and restarting...",
position: "bottom", position: "bottom",
destroyOnClose: true, destroyOnClose: true,
closeTimeout: 1000 * 10 closeTimeout: 1000 * 10
}); });
syncNow(function () { syncNow(function () {
restartApplication(); restartApplication();
}); });
} }
function clearCaches() {
app.toast.show({
text: "Clearing caches. You may need to restart the app to see a difference.",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 10
});
setStorage("geocode_cache", "{}");
if ('caches' in window) {
clearAllCaches();
}
}
$('.item-content[data-setting=darktheme] .toggle input').on("change", function () { $('.item-content[data-setting=darktheme] .toggle input').on("change", function () {
var checked = $(this).prop('checked'); var checked = $(this).prop('checked');
setStorage("darktheme", checked); setStorage("darktheme", checked);

View File

@ -113,7 +113,6 @@ var cachedurls = [
'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff', 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff',
'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2' 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2'
]; ];
for (i in SETTINGS.maptileurls) { for (i in SETTINGS.maptileurls) {
cachedurls.push(SETTINGS.maptileurls[i].json); cachedurls.push(SETTINGS.maptileurls[i].json);
} }
@ -157,4 +156,12 @@ function fillCache(cachename) {
}, 1000 * 30); }, 1000 * 30);
} }
} }
}
async function clearAllCaches() {
const keys = await caches.keys();
for (const key of keys) {
caches.delete(key);
}
} }

View File

@ -388,6 +388,13 @@ var routes = [
text: "", text: "",
onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=PackageHelperApp')", onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=PackageHelperApp')",
link: true link: true
},
{
setting: "clearcache",
title: "Clear Cache",
text: "Delete saved maps and other temporary data",
link: true,
onclick: "clearCaches()"
}); });
resolve({ resolve({
templateUrl: './pages/settings.html' templateUrl: './pages/settings.html'