Fixed critical issues causing tracking pages to display black: 1. PWA service worker caching old JavaScript chunks 2. Missing auth Redux slice causing undefined errors ## Service Worker Update Checker - Added /public/check-updates.js script - Checks for SW updates every 60 seconds - Auto-reloads page when new SW is activated - Forces update check on page load - Prevents future cache staleness issues ## Auth Redux Slice - Created store/slices/authSlice.ts with User interface - Added auth reducer to Redux store configuration - Included auth in persist whitelist - Provides selectors: selectUser, selectFamilyId, etc. - Fixes "Cannot read properties of undefined (reading 'user')" error ## Root Cause Tracking pages reference state.auth.user.familyId but auth slice didn't exist in Redux store, causing TypeError on all tracking pages. Build: ✅ PASSED Files: 3 new, 2 modified 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
27 lines
706 B
JavaScript
27 lines
706 B
JavaScript
/**
|
|
* Service Worker Update Checker
|
|
* Detects when a new build is available and prompts user to reload
|
|
*/
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
// Check for updates every 60 seconds
|
|
setInterval(() => {
|
|
navigator.serviceWorker.getRegistration().then(registration => {
|
|
if (registration) {
|
|
registration.update();
|
|
}
|
|
});
|
|
}, 60000);
|
|
|
|
// Listen for service worker updates
|
|
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
|
console.log('[SW] New service worker activated, reloading page...');
|
|
window.location.reload();
|
|
});
|
|
|
|
// Force update check on load
|
|
navigator.serviceWorker.ready.then(registration => {
|
|
registration.update();
|
|
});
|
|
}
|