Remove service worker for now (it clashed with notifications implementation)

This commit is contained in:
Jason McBrayer 2018-09-24 10:32:30 -04:00
parent 4c3407d87e
commit af4173742b
4 changed files with 1 additions and 52 deletions

View File

@ -171,22 +171,9 @@
$(document).ready(function () { $(document).ready(function () {
menuPrepare(); menuPrepare();
}); });
if (navigator.serviceWorker.controller) {
console.log('[PWA Builder] active service worker found, no need to register')
} else {
//Register the ServiceWorker
navigator.serviceWorker.register('pwabuilder-sw.js', {
scope: '{% url '' %}'
}).then(function(reg) {
console.log('Service worker has been registered for scope:'+ reg.scope);
});
}
Intercooler.ready(function () Intercooler.ready(function ()
{ {
$(".attachments").photobox('a', { history: true }); $(".attachments").photobox('a', { history: false });
var refresh = new Event('refreshOffline');
self.dispatchEvent(refresh);
}); });
</script> </script>
{% block page_scripts_inline %} {% block page_scripts_inline %}

View File

@ -1,35 +0,0 @@
//This is the "Offline page" service worker
{% load static %}
//Install stage sets up the offline page in the cache and opens a new cache
self.addEventListener('install', function(event) {
var offlinePage = new Request('{% static "offline.html" %}');
event.waitUntil(
fetch(offlinePage).then(function(response) {
return caches.open('pwabuilder-offline').then(function(cache) {
console.log('[PWA Builder] Cached offline page during Install'+ response.url);
return cache.put(offlinePage, response);
});
}));
});
//If any fetch fails, it will show the offline page.
//Maybe this should be limited to HTML documents?
self.addEventListener('fetch', function(event) {
event.respondWith(
fetch(event.request).catch(function(error) {
console.error( '[PWA Builder] Network request Failed. Serving offline page ' + error );
return caches.open('pwabuilder-offline').then(function(cache) {
return cache.match('{% static "offline.html" %}');
});
}
));
});
//This is a event that can be fired from your page to tell the SW to update the offline page
self.addEventListener('refreshOffline', function(response) {
return caches.open('pwabuilder-offline').then(function(cache) {
console.log('[PWA Builder] Offline page updated from refreshOffline event: '+ response.url);
return cache.put(offlinePage, response);
});
});

View File

@ -58,6 +58,5 @@ urlpatterns = [
path('search', views.search, name='search'), path('search', views.search, name='search'),
path('search_results', views.search_results, name='search_results'), path('search_results', views.search_results, name='search_results'),
path('emoji', views.emoji_reference, name='emoji'), path('emoji', views.emoji_reference, name='emoji'),
path('pwabuilder-sw.js', views.service_worker, name="sw"),
path('', views.home, name=''), path('', views.home, name=''),
] ]

View File

@ -822,5 +822,3 @@ def emoji_reference(request):
"notifications": notifications, "notifications": notifications,
'own_acct' : request.session['user']}) 'own_acct' : request.session['user']})
def service_worker(request):
return render(request, 'pwabuilder-sw.js', content_type="application/javascript")