Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

fix: pwa not loading static files when offline (#241)

Miguel Ribeiro4e3376df93ea
diff --git a/includes/version.php b/includes/version.php
index 569ddaa..9b4637d 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
- $version = "v1.17.1";
+ $version = "v1.17.2";
?>
\ No newline at end of file
diff --git a/service-worker.js b/service-worker.js
index f365388..30c545b 100644
--- a/service-worker.js
+++ b/service-worker.js
@@ -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',
@@ -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',
@@ -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);
+ }
+ });
+ });
})
);
});
@@ -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 });
})
);
});
\ No newline at end of file