aboutsummaryrefslogtreecommitdiff
path: root/ui/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/static/js')
-rw-r--r--ui/static/js/bootstrap.js7
-rw-r--r--ui/static/js/sw.js14
2 files changed, 21 insertions, 0 deletions
diff --git a/ui/static/js/bootstrap.js b/ui/static/js/bootstrap.js
index 98ad6351..bd3b09ee 100644
--- a/ui/static/js/bootstrap.js
+++ b/ui/static/js/bootstrap.js
@@ -71,4 +71,11 @@ document.addEventListener("DOMContentLoaded", function() {
mouseHandler.onClick(".logo", () => menuHandler.toggleMainMenu());
mouseHandler.onClick(".header nav li", (event) => menuHandler.clickMenuListItem(event));
}
+
+ if ("serviceWorker" in navigator) {
+ let scriptElement = document.getElementById("service-worker-script");
+ if (scriptElement) {
+ navigator.serviceWorker.register(scriptElement.src);
+ }
+ }
});
diff --git a/ui/static/js/sw.js b/ui/static/js/sw.js
new file mode 100644
index 00000000..8e32fcbb
--- /dev/null
+++ b/ui/static/js/sw.js
@@ -0,0 +1,14 @@
+self.addEventListener("fetch", (event) => {
+ if (event.request.url.includes("/feed/icon/")) {
+ event.respondWith(
+ caches.open("feed_icons").then((cache) => {
+ return cache.match(event.request).then((response) => {
+ return response || fetch(event.request).then((response) => {
+ cache.put(event.request, response.clone());
+ return response;
+ });
+ });
+ })
+ );
+ }
+});