lemmy-ui/src/service-worker.ts

29 lines
708 B
TypeScript
Raw Normal View History

2021-02-22 02:39:04 +00:00
import { register } from "register-service-worker";
2021-02-22 02:39:04 +00:00
register("/service-worker.js", {
registrationOptions: { scope: "./" },
ready() {
2021-02-22 02:39:04 +00:00
console.log("Service worker is active.");
2021-01-24 18:52:52 +00:00
},
registered() {
2021-02-22 02:39:04 +00:00
console.log("Service worker has been registered.");
2021-01-24 18:52:52 +00:00
},
cached() {
2021-02-22 02:39:04 +00:00
console.log("Content has been cached for offline use.");
2021-01-24 18:52:52 +00:00
},
updatefound() {
2021-02-22 02:39:04 +00:00
console.log("New content is downloading.");
2021-01-24 18:52:52 +00:00
},
updated() {
2021-02-22 02:39:04 +00:00
console.log("New content is available; please refresh.");
2021-01-24 18:52:52 +00:00
},
offline() {
console.log(
2021-02-22 02:39:04 +00:00
"No internet connection found. App is running in offline mode."
);
},
error(error) {
2021-02-22 02:39:04 +00:00
console.error("Error during service worker registration:", error);
},
});