File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
packages/web/src/common/hooks Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import { useEffect } from "react";
66 */
77export const useChunkLoadErrorHandler = ( ) => {
88 useEffect ( ( ) => {
9+ let isReloading = false ;
10+
911 const handleError = ( event : ErrorEvent ) => {
12+ if ( isReloading ) return ;
13+
1014 const isChunkLoadError =
1115 event . message ?. includes ( "Loading chunk" ) ||
1216 event . message ?. includes ( "ChunkLoadError" ) ||
@@ -20,12 +24,17 @@ export const useChunkLoadErrorHandler = () => {
2024 // Prevent default error handling
2125 event . preventDefault ( ) ;
2226
27+ // Set flag to prevent multiple reloads
28+ isReloading = true ;
29+
2330 // Reload the page to get the new chunks
2431 window . location . reload ( ) ;
2532 }
2633 } ;
2734
2835 const handleUnhandledRejection = ( event : PromiseRejectionEvent ) => {
36+ if ( isReloading ) return ;
37+
2938 const isChunkLoadError =
3039 event . reason ?. message ?. includes ( "Loading chunk" ) ||
3140 event . reason ?. name === "ChunkLoadError" ;
@@ -38,6 +47,9 @@ export const useChunkLoadErrorHandler = () => {
3847 // Prevent default error handling
3948 event . preventDefault ( ) ;
4049
50+ // Set flag to prevent multiple reloads
51+ isReloading = true ;
52+
4153 // Reload the page to get the new chunks
4254 window . location . reload ( ) ;
4355 }
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export const useVersionCheck = (): VersionCheckResult => {
4747 const serverVersion = data . version ;
4848
4949 // Check if server version differs from current version
50+ // Once an update is detected, we keep showing the indicator
51+ // until the user refreshes to get the new version
5052 if ( serverVersion && serverVersion !== CURRENT_VERSION ) {
5153 setIsUpdateAvailable ( true ) ;
5254 }
You can’t perform that action at this time.
0 commit comments