Skip to content

Commit

Permalink
feat: sw auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 24, 2023
1 parent 8390b54 commit cb0ec59
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 63 deletions.
7 changes: 1 addition & 6 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { RootLayout } from '@/common/components/layout';
import {
AlertOffline,
IosInstallGuide,
UpdateBanner,
} from '@/common/components/system';
import { AlertOffline, IosInstallGuide } from '@/common/components/system';
import { GlobalErrorBoundary } from './GlobalErrorBoundary';
import { Provider } from './Provider';
import Routes from './Routes';
Expand All @@ -14,7 +10,6 @@ export function App() {
<RootLayout>
<GlobalErrorBoundary>
<AlertOffline />
<UpdateBanner />
<IosInstallGuide />
<Routes />
</GlobalErrorBoundary>
Expand Down
19 changes: 0 additions & 19 deletions src/common/components/system/UpdateBanner/UpdateBanner.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/common/components/system/UpdateBanner/index.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/common/hooks/useUpdate.tsx

This file was deleted.

8 changes: 3 additions & 5 deletions src/my-sw.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { clientsClaim } from 'workbox-core';
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';

declare let self: ServiceWorkerGlobalScope;
Expand All @@ -6,8 +7,5 @@ cleanupOutdatedCaches();

precacheAndRoute(self.__WB_MANIFEST);

self.addEventListener('message', (event) => {
if (event.data && event.data.type === 'SKIP_WAITING') {
self.skipWaiting();
}
});
self.skipWaiting();
clientsClaim();
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
}),
svgr(),
VitePWA({
registerType: 'prompt',
registerType: 'autoUpdate',
strategies: 'injectManifest',
injectManifest: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2,otf}'],
Expand Down

0 comments on commit cb0ec59

Please sign in to comment.