Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
commit
330cb62fd0
|
@ -34,7 +34,8 @@ class PushNews extends Notification
|
|||
->title('Ny Nyhed')
|
||||
->icon('/images/icons/appIcon.png')
|
||||
->body('Der er en ny nyhed i ekapp\'en')
|
||||
->action('Se nyheder', 'root.index');
|
||||
->badge('/images/icons/appIcon.png')
|
||||
->action('Se nyheder', route('root.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,7 +25,6 @@ const assets = [
|
|||
'/images/logos/Logo-hvid.svg',
|
||||
'/images/logos/Logo-normal.svg',
|
||||
'/images/icons/Logout.svg'
|
||||
|
||||
];
|
||||
|
||||
// install event
|
||||
|
@ -58,16 +57,20 @@ self.addEventListener('activate', evt => {
|
|||
|
||||
self.addEventListener('fetch', evt => {
|
||||
console.log('fetch event');
|
||||
|
||||
if(!navigator.onLine)
|
||||
evt.respondWith(
|
||||
caches.match(evt.request).then(cacheRes => {
|
||||
return cacheRes || fetch(evt.request).then(fetchRes => {
|
||||
return cacheRes || caches.match('/offline.html');
|
||||
})
|
||||
);
|
||||
else
|
||||
evt.respondWith(
|
||||
fetch(evt.request).then(fetchRes => {
|
||||
return caches.open(dynamicCacheName).then(cache => {
|
||||
cache.put(evt.request.url, fetchRes.clone());
|
||||
return fetchRes;
|
||||
})
|
||||
});
|
||||
}).catch(function () {
|
||||
return caches.match('/offline.html');
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -84,7 +87,18 @@ self.addEventListener('push', function(event) {
|
|||
event.waitUntil(self.registration.showNotification(msg.title, {
|
||||
body: msg.body,
|
||||
icon: msg.icon,
|
||||
badge: msg.badge,
|
||||
actions: msg.actions
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
|
||||
if (event.action === 'some_action') {
|
||||
self.clients.openWindow('/home');
|
||||
} else {
|
||||
self.clients.openWindow('/')
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue