@@ -27,6 +27,7 @@ import {PrimaryModal} from 'Components/Modals/PrimaryModal';
2727import { removeCurrentModal } from 'Components/Modals/PrimaryModal/PrimaryModalState' ;
2828import { CellsRepository } from 'Repositories/cells/cellsRepository' ;
2929import { Config } from 'src/script/Config' ;
30+ import { useApplicationContext } from 'src/script/page/RootProvider' ;
3031import { t } from 'Util/localizerUtil' ;
3132import { TIME_IN_MILLIS } from 'Util/timeUtil' ;
3233
@@ -43,6 +44,7 @@ interface FileEditorProps {
4344
4445export const FileEditor = ( { id} : FileEditorProps ) => {
4546 const cellsRepository = container . resolve ( CellsRepository ) ;
47+ const { fireAndForgetInvoker} = useApplicationContext ( ) ;
4648 const [ node , setNode ] = useState < Node | null > ( null ) ;
4749 const [ isRecycled , setIsRecycled ] = useState ( false ) ;
4850 const [ isLoading , setIsLoading ] = useState ( true ) ;
@@ -74,18 +76,19 @@ export const FileEditor = ({id}: FileEditorProps) => {
7476
7577 const handleRetry = useCallback ( ( ) => {
7678 hasShownErrorModal . current = false ;
77- void ( async ( ) => {
79+
80+ fireAndForgetInvoker . fireAndForget ( async ( ) : Promise < void > => {
7881 const isSuccessful = await fetchNode ( ) ;
7982 if ( isSuccessful ) {
8083 removeCurrentModal ( ) ;
8184 }
82- } ) ( ) ;
83- } , [ fetchNode ] ) ;
85+ } ) ;
86+ } , [ fetchNode , fireAndForgetInvoker ] ) ;
8487
8588 // Initial fetch
8689 useEffect ( ( ) => {
87- void fetchNode ( ) ;
88- } , [ id , cellsRepository , fetchNode ] ) ;
90+ fireAndForgetInvoker . fireAndForget ( fetchNode ) ;
91+ } , [ fetchNode , fireAndForgetInvoker ] ) ;
8992
9093 // Auto-refresh mechanism before expiry
9194 useEffect ( ( ) => {
@@ -98,16 +101,16 @@ export const FileEditor = ({id}: FileEditorProps) => {
98101
99102 // Set timeout to refresh before expiry
100103 const timeoutId = setTimeout ( ( ) => {
101- void fetchNode ( ) ;
104+ fireAndForgetInvoker . fireAndForget ( fetchNode ) ;
102105 } , refreshInSeconds * TIME_IN_MILLIS . SECOND ) ;
103106
104107 return ( ) => {
105108 clearTimeout ( timeoutId ) ;
106109 } ;
107- } , [ node , fetchNode ] ) ;
110+ } , [ fetchNode , fireAndForgetInvoker , node ] ) ;
108111
109112 useEffect ( ( ) => {
110- if ( isLoading || isRecycled || ( ! isError && node ) ) {
113+ if ( isLoading || isRecycled || ( ! isError && node !== null ) ) {
111114 return ;
112115 }
113116
@@ -134,7 +137,7 @@ export const FileEditor = ({id}: FileEditorProps) => {
134137 } , [ handleRetry , isError , isLoading , isRecycled , node ] ) ;
135138
136139 useEffect ( ( ) => {
137- if ( ! isLoading && ! isError && node && ! isRecycled ) {
140+ if ( ! isLoading && ! isError && node !== null && ! isRecycled ) {
138141 hasShownErrorModal . current = false ;
139142 }
140143 } , [ isError , isLoading , isRecycled , node ] ) ;
0 commit comments