Fixing ServiceWorker Clear Cache
This commit is contained in:
parent
ae5257b2b3
commit
b05e2d3c55
@ -27,20 +27,9 @@ self.addEventListener('activate', (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('message', (event) => {
|
self.addEventListener('message', (event) => {
|
||||||
if (event.data === "clear_cache") {
|
log("Clearing cache");
|
||||||
log("Clearing cache");
|
caches.delete(CACHE);
|
||||||
caches.delete(CACHE);
|
event.waitUntil(precache());
|
||||||
event.waitUntil(precache());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.data === "update_index") {
|
|
||||||
log("Updating index");
|
|
||||||
event.waitUntil(caches.open(CACHE).then((cache) => {
|
|
||||||
return cache.addAll(["/", "/index.html"]).then(() => {
|
|
||||||
event.ports[0].postMessage("reload");
|
|
||||||
});
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var Types;
|
var Types;
|
||||||
|
@ -30,7 +30,7 @@ export default class SettingsPage extends Page<{ state: any }, { vault: string }
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{/* <button class="btn" onClick={() => Theme.toggle()}>Toggle Dark Mode</button> */}
|
{/* <button class="btn" onClick={() => Theme.toggle()}>Toggle Dark Mode</button> */}
|
||||||
<button class="btn" onClick={() => window.navigator.serviceWorker.controller.postMessage("clear_cache")}>Clear cache</button>
|
<button class="btn" onClick={() => window.navigator.serviceWorker.controller.postMessage("message")}>Clear cache</button>
|
||||||
</div>
|
</div>
|
||||||
</div >;
|
</div >;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user