diff --git a/public/serviceworker.js b/public/serviceworker.js index 8e22bc1..8eaf4f9 100644 --- a/public/serviceworker.js +++ b/public/serviceworker.js @@ -48,19 +48,12 @@ var Types; Types[Types["REFRESH"] = 2] = "REFRESH"; })(Types || (Types = {})); -let rules = [ - { +let rules = [{ match: (url) => { return url.indexOf("/api/") >= 0; }, type: Types.NOCACHE }, - { - match: (url) => { - return url.indexOf("/version_hash") >= 0; - }, - type: Types.NOCACHE - }, { match: () => { return true; @@ -79,7 +72,7 @@ self.addEventListener('fetch', (evt) => { return fromCache(evt.request); case Types.REFRESH: return refresh(evt.request).then(r => { - evt.waitUntil(r.refresh.catch(_ => { })); + evt.waitUntil(r.refresh.catch(_ => {})); return r.result; }); case Types.NOCACHE: @@ -95,7 +88,12 @@ async function fromCache(request) { return matching let res = await fetch(request.clone()); - await cache.put(request, res); + await cache.put(request, { + match: (url) => { + return url.indexOf("/version_hash") >= 0; + }, + type: Types.NOCACHE + }, res); return await cache.match(request); } diff --git a/src/notes.ts b/src/notes.ts index ad7d5bc..8dd2a51 100644 --- a/src/notes.ts +++ b/src/notes.ts @@ -167,7 +167,7 @@ class NotesProvider { public async start() { const next = () => { setTimeout(() => { - this.sync().then(() => next); + this.sync().then(next); }, 30000) } this.syncedObservableServer.send((await this.oplogDB.getAll()).length <= 0);