Skip to content

Commit

Permalink
fix: pwa not loading static files when offline (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellite authored Mar 18, 2024
1 parent 560f5e3 commit 4e3376d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$version = "v1.17.1";
$version = "v1.17.2";
?>
16 changes: 13 additions & 3 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('my-cache').then(function(cache) {
return cache.addAll([
const urlsToCache = [
'.',
'index.php',
'settings.php',
Expand Down Expand Up @@ -36,6 +36,8 @@ self.addEventListener('install', function(event) {
'scripts/libs/chart.js',
'scripts/libs/sortable.min.js',
'images/icon/favicon.ico',
'images/icon/android-chrome-192x192.png',
'images/screenshots/desktop.png',
'images/wallossolid.png',
'images/wallossolidwhite.png',
'images/siteimages/empty.png',
Expand Down Expand Up @@ -96,7 +98,15 @@ self.addEventListener('install', function(event) {
'images/uploads/icons/venmo.png',
'images/uploads/icons/verifone.png',
'images/uploads/icons/webmoney.png',
]);
];

urlsToCache.forEach(function(url) {
fetch(url).then(function(response) {
if (response.ok) {
cache.put(url, response);
}
});
});
})
);
});
Expand All @@ -114,7 +124,7 @@ self.addEventListener('fetch', function(event) {
}
}).catch(function(error) {
// If fetching fails, try to retrieve the response from cache
return caches.match(event.request);
return caches.match(event.request, { ignoreSearch: true });
})
);
});

0 comments on commit 4e3376d

Please sign in to comment.