File tree Expand file tree Collapse file tree 3 files changed +7
-1
lines changed
Expand file tree Collapse file tree 3 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export class CurrentUser {
1212 private reconnectTimeoutId : number | null = null ;
1313 private reconnectTime = 7500 ;
1414 public loggedIn = false ;
15+ public refreshKey = 0 ;
1516 public authenticating = true ;
1617 public user : IUser = { name : 'unknown' , admin : false , id : - 1 } ;
1718 public connectionErrorMessage : string | null = null ;
@@ -22,6 +23,7 @@ export class CurrentUser {
2223 authenticating : observable ,
2324 user : observable ,
2425 connectionErrorMessage : observable ,
26+ refreshKey : observable ,
2527 } ) ;
2628 }
2729
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ const Layout = observer(() => {
5858 logout,
5959 tryReconnect,
6060 connectionErrorMessage,
61+ refreshKey,
6162 } ,
6263 } = useStores ( ) ;
6364 const { classes} = useStyles ( ) ;
@@ -84,7 +85,9 @@ const Layout = observer(() => {
8485 < StyledEngineProvider injectFirst >
8586 < ThemeProvider theme = { theme } >
8687 < HashRouter >
87- < div >
88+ { /* This forces all components to fully rerender including useEffects.
89+ The refreshKey is updated when store data was cleaned and pages should refetch their data. */ }
90+ < div key = { refreshKey } >
8891 { ! connectionErrorMessage ? null : (
8992 < ConnectionErrorBanner
9093 height = { 64 }
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export const registerReactions = (stores: StoreMapping) => {
4040 if ( ! connectionErrorMessage ) {
4141 clearAll ( ) ;
4242 loadAll ( ) ;
43+ stores . currentUser . refreshKey ++ ;
4344 }
4445 }
4546 ) ;
You can’t perform that action at this time.
0 commit comments