From 6af15e4cfdc31373cc0baf4a4d9a5a398ea9ad88 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 27 Dec 2025 15:57:38 +0000 Subject: [PATCH] Reload spots/alerts on visibility change. Closes #89 --- templates/about.html | 2 +- templates/add_spot.html | 4 ++-- templates/alerts.html | 4 ++-- templates/bands.html | 6 +++--- templates/map.html | 6 +++--- templates/spots.html | 6 +++--- templates/status.html | 4 ++-- webassets/js/alerts.js | 8 ++++++++ webassets/js/spotsbandsandmap.js | 10 +++++++++- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/templates/about.html b/templates/about.html index e7ddb71..1eeb600 100644 --- a/templates/about.html +++ b/templates/about.html @@ -63,7 +63,7 @@

This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.

- + {% end %} \ No newline at end of file diff --git a/templates/add_spot.html b/templates/add_spot.html index 4b67e16..51f18d2 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -69,8 +69,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/alerts.html b/templates/alerts.html index c404b99..a68c185 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -168,8 +168,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/bands.html b/templates/bands.html index 80a967b..8391f8a 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -129,9 +129,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/map.html b/templates/map.html index 1f1c1e8..9a3024e 100644 --- a/templates/map.html +++ b/templates/map.html @@ -147,9 +147,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/spots.html b/templates/spots.html index 76c437b..1b34a62 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -218,9 +218,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/status.html b/templates/status.html index 12a0b99..8ca719c 100644 --- a/templates/status.html +++ b/templates/status.html @@ -3,8 +3,8 @@
- - + + {% end %} \ No newline at end of file diff --git a/webassets/js/alerts.js b/webassets/js/alerts.js index 55b01bc..4363c72 100644 --- a/webassets/js/alerts.js +++ b/webassets/js/alerts.js @@ -351,4 +351,12 @@ $(document).ready(function() { loadOptions(); // Update the refresh timing display every second setInterval(updateRefreshDisplay, 1000); +}); + +// Reload alerts on becoming visible. This forces a refresh when used as a PWA and the user switches back to the PWA +// after some time has passed with it in the background. +addEventListener("visibilitychange", (event) => { + if (!document.hidden) { + loadAlerts(); + } }); \ No newline at end of file diff --git a/webassets/js/spotsbandsandmap.js b/webassets/js/spotsbandsandmap.js index 5dcf048..5a8e1cd 100644 --- a/webassets/js/spotsbandsandmap.js +++ b/webassets/js/spotsbandsandmap.js @@ -49,4 +49,12 @@ function filtersUpdated() { function toggleDarkMode() { enableDarkMode($("#darkMode")[0].checked); saveSettings(); -} \ No newline at end of file +} + +// Reload spots on becoming visible. This forces a refresh when used as a PWA and the user switches back to the PWA +// after some time has passed with it in the background. +addEventListener("visibilitychange", (event) => { + if (!document.hidden) { + loadSpots(); + } +}); \ No newline at end of file