Browse Source

Merge 99fd654e4b into fd758f2ce5

pull/135/merge
jamestthompson3 3 years ago
committed by GitHub
parent
commit
0d379f5a40
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      public/js/manifest.json
  2. 7
      public/js/register-sw.js
  3. 14
      public/js/sw.js
  4. 1
      views/index.php

3
public/js/manifest.json

@ -2,6 +2,9 @@
"name": "Quill",
"short_name": "Quill",
"description": "Quill is a simple app for posting to your website",
"background_color": "#428bca",
"display": "standalone",
"start_url": "/dashboard",
"icons": [
{
"src": "/images/quill-icon-57.png",

7
public/js/register-sw.js

@ -0,0 +1,7 @@
(function registerSW() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/js/sw.js").catch((e) => {
console.log("Registration fail: ", e);
});
}
})();

14
public/js/sw.js

@ -0,0 +1,14 @@
// NOTE: This currently doesn't cache anything
// We are just installing it so that chrome users can be
// prompted to install Quill via add to homescreen
self.addEventListener("install", installWorker);
async function installWorker() {
await self.skipWaiting();
}
self.addEventListener("activate", activateServiceWorker);
async function activateServiceWorker(event) {
event.waitUntil(clients.claim()); // make the current sw the active sw in all pages
}

1
views/index.php

@ -32,4 +32,5 @@
<a href="" class="u-url"></a>
</div>
<script src="/js/register-sw.js"></script>
</div>
Loading…
Cancel
Save