Skip to content

Commit

Permalink
add pwa update notification
Browse files Browse the repository at this point in the history
  • Loading branch information
poliva committed Sep 3, 2024
1 parent a28057c commit ad71999
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ $("#cube").on('touchstart', () => {
});
*/

if ('serviceWorker' in navigator) {
navigator.serviceWorker.addEventListener('controllerchange', () => {
if (confirm('New version available. Refresh now?')) {
window.location.reload();
}
});
}

let wakeLock: WakeLockSentinel | null = null;

// Function to request a wake lock
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default defineConfig({
]
},
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
skipWaiting: true,
globPatterns: ['**/*.{js,css,html,png,svg}'],
runtimeCaching: [
{
Expand Down

0 comments on commit ad71999

Please sign in to comment.