remove manual update prompt UI and enable automatic silent service worker updates
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
import { useRegisterSW } from 'virtual:pwa-register/react';
|
import { useRegisterSW } from 'virtual:pwa-register/react';
|
||||||
import { RefreshCw } from 'lucide-react';
|
|
||||||
import { Button } from './Button';
|
|
||||||
|
|
||||||
// Check for SW updates every hour and on tab focus/visibility change
|
// Check for SW updates every hour and on tab focus/visibility change
|
||||||
const UPDATE_INTERVAL_MS = 60 * 60 * 1000;
|
const UPDATE_INTERVAL_MS = 60 * 60 * 1000;
|
||||||
@@ -33,23 +32,12 @@ export function UpdatePrompt() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!needRefresh) return null;
|
useEffect(() => {
|
||||||
|
if (needRefresh) {
|
||||||
|
console.log('[PWA] New version detected, auto-updating...');
|
||||||
|
updateServiceWorker(true);
|
||||||
|
}
|
||||||
|
}, [needRefresh, updateServiceWorker]);
|
||||||
|
|
||||||
return (
|
return null;
|
||||||
<div className="fixed top-0 inset-x-0 z-[60] bg-[#1B263B] text-white shadow-lg">
|
|
||||||
<div className="max-w-7xl mx-auto px-4 py-2 flex items-center justify-between gap-3">
|
|
||||||
<div className="flex items-center gap-2 text-sm">
|
|
||||||
<RefreshCw size={16} className="shrink-0" />
|
|
||||||
<span>Доступна новая версия приложения</span>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
onClick={() => updateServiceWorker(true)}
|
|
||||||
className="bg-white text-[#1B263B] hover:bg-white/90"
|
|
||||||
>
|
|
||||||
Обновить
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user