Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWA Improvements #135

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/js/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions public/js/register-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function registerSW() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/js/sw.js").catch((e) => {
console.log("Registration fail: ", e);
});
}
})();
14 changes: 14 additions & 0 deletions public/js/sw.js
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
<a href="" class="u-url"></a>
</div>

<script src="/js/register-sw.js"></script>
</div>