talk2me/static/pwa-update.js
Adolfo Delorenzo d818ec7d73 Major PWA and mobile UI improvements
- Fixed PWA installation on Android by correcting manifest.json icon configuration
- Made UI mobile-friendly with compact layout and sticky record button
- Implemented auto-translation after transcription stops
- Updated branding from 'Voice Translator' to 'Talk2Me' throughout
- Added reverse proxy support with ProxyFix middleware
- Created diagnostic tools for PWA troubleshooting
- Added proper HTTP headers for service worker and manifest
- Improved mobile CSS with responsive design
- Fixed JavaScript bundling with webpack configuration
- Updated service worker cache versioning
- Added comprehensive PWA documentation

These changes ensure the app works properly as a PWA on Android devices
and provides a better mobile user experience.
2025-06-03 12:28:09 -06:00

41 lines
1.2 KiB
JavaScript

// PWA Update Helper
// This script helps force PWA updates on clients
// Force service worker update
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
registration.unregister().then(function() {
console.log('Service worker unregistered');
});
}
});
// Re-register after a short delay
setTimeout(function() {
navigator.serviceWorker.register('/service-worker.js')
.then(function(registration) {
console.log('Service worker re-registered');
registration.update();
});
}, 1000);
}
// Clear all caches
if ('caches' in window) {
caches.keys().then(function(names) {
for (let name of names) {
caches.delete(name);
console.log('Cache cleared:', name);
}
});
}
// Reload manifest
var link = document.querySelector('link[rel="manifest"]');
if (link) {
link.href = link.href + '?v=' + Date.now();
console.log('Manifest reloaded');
}
console.log('PWA update complete. Please reload the page.');