diff --git a/ui/src/views/version/UpdateNotifier.tsx b/ui/src/views/version/UpdateNotifier.tsx index d24abfdb..d5feaf63 100644 --- a/ui/src/views/version/UpdateNotifier.tsx +++ b/ui/src/views/version/UpdateNotifier.tsx @@ -1,4 +1,3 @@ -import { ROUTES_ENUM } from '@/routes/route.constant' import { useState, useEffect } from 'react' import { HiOutlineRefresh, HiX } from 'react-icons/hi' import { useStoreActions } from '@/store' @@ -50,10 +49,16 @@ const UpdateNotifier = () => { reg.waiting.postMessage({ type: 'SKIP_WAITING' }) reg.waiting.addEventListener('statechange', (e: any) => { if (e.target.state === 'activated') { + if (newVersion) { + setUiVersion(newVersion) // ✅ Store’daki versiyonu güncelle + } window.location.reload() } }) } else { + if (newVersion) { + setUiVersion(newVersion) // ✅ Direkt güncelle + } window.location.reload() } }) diff --git a/ui/src/views/version/swRegistration.ts b/ui/src/views/version/swRegistration.ts index c5a57b16..5d115865 100644 --- a/ui/src/views/version/swRegistration.ts +++ b/ui/src/views/version/swRegistration.ts @@ -3,7 +3,6 @@ import { registerSW } from 'virtual:pwa-register' export const registerServiceWorker = () => { registerSW({ - immediate: true, // Yeni SW hemen yüklensin onNeedRefresh() { const event = new CustomEvent('sw-update-available') window.dispatchEvent(event) diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 516faa00..f18e453b 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -22,7 +22,7 @@ export default defineConfig(async ({ mode }) => { mode === 'production' ? VitePWA({ // Deploy'dan sonra otomatik güncelle - registerType: 'autoUpdate', + registerType: 'prompt', // Kayıt kodunu otomatik enjekte et (virtual:pwa-register yazmadan da çalışır) injectRegister: 'auto', // Dev ortamında SW'yi aç, prod'da kapalı tut (build edilmiş SW prod'da zaten aktif olur) @@ -37,10 +37,10 @@ export default defineConfig(async ({ mode }) => { // EN KRİTİK: yeni SW beklemeden kontrolü alsın clientsClaim: true, - skipWaiting: true, + skipWaiting: false, // Eski workbox cache'lerini temizle - cleanupOutdatedCaches: mode === 'production', + cleanupOutdatedCaches: true, // SPA fallback'i API çağrılarına uygulama navigateFallbackDenylist: [/^\/api\//],