Skip to content

Commit

Permalink
reload page when entering foreground after 1 hour wait period
Browse files Browse the repository at this point in the history
  • Loading branch information
fnschmidt committed Aug 23, 2024
1 parent f99923f commit 5a03d77
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
const drawerStore = getDrawerStore();
import { load_cc } from '$lib/cc';
import { browser } from '$app/environment';
load_cc();
const popupRechtliches: PopupSettings = {
Expand All @@ -41,6 +42,25 @@
// Defines which side of your trigger the popup will appear
placement: 'bottom'
};
const reloadInterval = 60 * 60 * 1000; // 1 hour in milliseconds
const start = Date.now();
function check_needs_reload() {
const now = Date.now();
const diff = now - start;
if (diff > reloadInterval) {
location.reload();
}
}
if (browser) {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
check_needs_reload();
}
});
}
</script>

<div
Expand Down

0 comments on commit 5a03d77

Please sign in to comment.