more pwa stuff

This commit is contained in:
Kasper Rynning-Tønnesen
2020-01-29 17:51:09 +01:00
parent 2d7de7c62b
commit 13e8f47b35
5 changed files with 27 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -11,6 +11,16 @@
"src": "/public/assets/images/android-chrome-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "/public/assets/images/192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/public/assets/images/512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#daeedd",

View File

@@ -30,16 +30,17 @@ self.addEventListener("fetch", event => {
event.respondWith(
fetch(event.request)
.then(response => cache(event.request, response))
.catch(function() {
return caches.match(event.request);
})
.catch(() => caches.match(event.request))
);
});
function cache(request, response) {
//console.log(response.type === "error" || response.type === "opaque", request);
if (response.type === "error" || response.type === "opaque") {
return response;
if (
response.type === "error" ||
!(response.url.includes("http:") && response.url.includes("https:")) ||
response.url == ""
) {
return Promise.resolve(response);
}
return caches.open(CACHE_NAME).then(cache => {

View File

@@ -52,11 +52,13 @@
</html>
<style>
noscript {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-size: 1.5rem;
}
</style>
noscript {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #dbeede;
font-size: 1.5rem;
font-family: Arial, Helvetica, sans-serif;
}
</style>