diff options
-rw-r--r-- | js/index.js | 21 | ||||
-rw-r--r-- | worker.js | 8 |
2 files changed, 18 insertions, 11 deletions
diff --git a/js/index.js b/js/index.js index 9c0f6a5..9aadc00 100644 --- a/js/index.js +++ b/js/index.js @@ -17,11 +17,24 @@ function cache_refresh(force) { navigator.serviceWorker.controller.postMessage("refresh-cache"); localforage.setItem("epube.cache-timestamp", ts); } else { - $(".dl-progress") - .show() - .addClass("alert-danger") - .html("Could not communicate with service worker. Try reloading the page."); + localforage.getItem("epube.initial-load-done").then(function(done) { + + console.log("initial load done", done); + + if (done) { + $(".dl-progress") + .show() + .addClass("alert-danger") + .html("Could not communicate with service worker. Try reloading the page."); + } else { + localforage.setItem("epube.initial-load-done", true).then(function() { + window.setTimeout(function() { + window.location.reload(); + }, 1000); + }); + } + }); } } @@ -40,15 +40,9 @@ const CACHE_URLS = [ 'lib/fonts/pmn-caecilia-75.ttf' ]; -/* self.addEventListener('install', function(event) { - event.waitUntil( - caches.open(CACHE_NAME).then(function(cache) { - return cache.addAll(CACHE_URLS.map((url) => new Request(url, {credentials: 'same-origin'}))); - }) - ); + self.skipWaiting(); }); -*/ self.addEventListener('activate', function(event) { event.waitUntil( |