diff --git a/www/assets/js/settings.js b/www/assets/js/settings.js index 94fa38d..6e402a1 100644 --- a/www/assets/js/settings.js +++ b/www/assets/js/settings.js @@ -20,16 +20,29 @@ function logout() { function resyncAndRestart() { app.toast.show({ - text: "Syncing settings and restarting...", - position: "bottom", - destroyOnClose: true, - closeTimeout: 1000 * 10 - }); + text: "Syncing settings and restarting...", + position: "bottom", + destroyOnClose: true, + closeTimeout: 1000 * 10 + }); syncNow(function () { 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 () { var checked = $(this).prop('checked'); setStorage("darktheme", checked); diff --git a/www/cache.js b/www/cache.js index 29760a0..60745ca 100644 --- a/www/cache.js +++ b/www/cache.js @@ -113,7 +113,6 @@ var cachedurls = [ 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff', 'node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2' ]; - for (i in SETTINGS.maptileurls) { cachedurls.push(SETTINGS.maptileurls[i].json); } @@ -157,4 +156,12 @@ function fillCache(cachename) { }, 1000 * 30); } } +} + +async function clearAllCaches() { + const keys = await caches.keys(); + + for (const key of keys) { + caches.delete(key); + } } \ No newline at end of file diff --git a/www/routes.js b/www/routes.js index 9ad7d7d..6b1caea 100644 --- a/www/routes.js +++ b/www/routes.js @@ -388,6 +388,13 @@ var routes = [ text: "", onclick: "openBrowser('https://netsyms.com/legal?pk_campaign=PackageHelperApp')", link: true + }, + { + setting: "clearcache", + title: "Clear Cache", + text: "Delete saved maps and other temporary data", + link: true, + onclick: "clearCaches()" }); resolve({ templateUrl: './pages/settings.html'