File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,18 @@ export default function App() {
195
195
} , 500 )
196
196
}
197
197
198
+ useEffect ( ( ) => {
199
+ if ( window . isSecureContext && navigator . serviceWorker ) {
200
+ // check for sw updates on page change
201
+ navigator . serviceWorker . getRegistrations ( ) . then ( ( regs ) => regs . forEach ( ( reg ) => reg . update ( ) ) )
202
+ if ( needRefresh ) {
203
+ update ( )
204
+ } else if ( toast . isActive ( updateToastRef . current ) ) {
205
+ toast . dismiss ( updateToastRef . current )
206
+ }
207
+ }
208
+ } , [ location ] )
209
+
198
210
function onUpdate ( ) {
199
211
const updateToastBody = (
200
212
< UpdateToast
@@ -213,16 +225,6 @@ export default function App() {
213
225
}
214
226
}
215
227
216
- useEffect ( ( ) => {
217
- if ( needRefresh ) {
218
- update ( )
219
- } else {
220
- if ( toast . isActive ( updateToastRef . current ) ) {
221
- toast . dismiss ( updateToastRef . current )
222
- }
223
- }
224
- } , [ location ] )
225
-
226
228
useEffect ( ( ) => {
227
229
if ( needRefresh ) {
228
230
onUpdate ( )
You can’t perform that action at this time.
0 commit comments