@@ -37,6 +37,8 @@ export const Main: FunctionComponent<MainProps> = props => {
3737 const [ error , setError ] = useState < { message : string ; code ?: number | string } > ( ) ;
3838 const [ isErrorDialogOpen , setIsErrorDialogOpen ] = useState < boolean > ( false ) ;
3939 const abortController = useRef < AbortController > ( new AbortController ( ) ) ;
40+ // Optional callback to run when the error dialog is dismissed (e.g. re-fetch stale data).
41+ const errorDialogOnClose = useRef < ( ( ) => void ) | undefined > ( undefined ) ;
4042
4143 useEffect ( ( ) => {
4244 getLoginProviders ( ) ;
@@ -83,20 +85,24 @@ export const Main: FunctionComponent<MainProps> = props => {
8385 }
8486 } ;
8587
86- const onError = ( err : Error | Partial < ErrorResponse > | ReportedError ) => {
88+ const onError = ( err : Error | Partial < ErrorResponse > | ReportedError , options ?: { onClose ?: ( ) => void } ) => {
8789 if ( err instanceof DOMException && err . message . trim ( ) === 'The operation was aborted.' ) {
8890 // ignore error caused by AbortController.abort()
8991 return ;
9092 }
9193
9294 const message = handleError ( err ) ;
9395 const code = ( err as ReportedError ) . code ;
96+ errorDialogOnClose . current = options ?. onClose ;
9497 setError ( { message, code } ) ;
9598 setIsErrorDialogOpen ( true ) ;
9699 } ;
97100
98101 const onErrorDialogClose = ( ) => {
99102 setIsErrorDialogOpen ( false ) ;
103+ const onClose = errorDialogOnClose . current ;
104+ errorDialogOnClose . current = undefined ;
105+ onClose ?.( ) ;
100106 } ;
101107
102108 const renderPageContent = ( ) : ReactNode => {
0 commit comments