First pass at bundling web app into service. Working.

This commit is contained in:
Gabe Kangas
2022-06-19 15:30:32 -07:00
parent 22ac8035fe
commit 78c6189c02
241 changed files with 437 additions and 178 deletions

View File

@@ -0,0 +1,25 @@
/* eslint-disable no-restricted-globals */
self.addEventListener('activate', event => {
console.log('Owncast service worker activated', event);
});
self.addEventListener('install', event => {
console.log('installing Owncast service worker...', event);
});
self.addEventListener('push', event => {
const data = JSON.parse(event.data.text());
const { title, body, icon, tag } = data;
const options = {
title: title || 'Live!',
body: body || 'This live stream has started.',
icon: icon || '/logo/external',
tag,
};
event.waitUntil(self.registration.showNotification(options.title, options));
});
self.addEventListener('notificationclick', event => {
clients.openWindow('/');
});