@@ -279,6 +279,12 @@ export default function JobsSelector(props: JobSelectorPropsType) {
279279 updateJobContext ( newJobCollections ) ;
280280 } , [ jobCollections , updateJobContext ] ) ;
281281
282+ const handleJobsUpdate = useCallback ( async ( ) => {
283+ setJobCollections ( [ ] ) ;
284+ await updateJobCollections ( selectedFunction ?. uid as string ) ;
285+ console . info ( "Updated JobCollections" ) ;
286+ } , [ selectedFunction , updateJobCollections ] ) ;
287+
282288 useEffect ( ( ) => {
283289 if ( jobCollections . length > 0 && loading === true ) {
284290 onToggleAll ( true ) ;
@@ -288,23 +294,15 @@ export default function JobsSelector(props: JobSelectorPropsType) {
288294 } , [ jobCollections , loading , onToggleAll , setIsSuMoGenerated , setLoading , updateJobContext ] ) ;
289295
290296 useEffect ( ( ) => {
291- console . info ( "useEffect in JobsSelector triggered" ) ;
292- if ( selectedFunction === undefined || jobCollections . length === 0 ) {
297+ console . info ( "useEffect in JobsSelector triggered" , selectedFunction , jobCollections ) ;
298+ if ( selectedFunction === undefined || jobCollections . length > 0 ) {
293299 return ;
294300 }
295301 console . info ( "Function selected: " , selectedFunction . uid ) ;
296- ( async ( ) => {
297- setJobCollections ( [ ] ) ;
298- await updateJobCollections ( selectedFunction ?. uid as string ) ;
299- console . info ( "Updated JobCollections" ) ;
300- } ) ( ) ;
302+ handleJobsUpdate ( ) ;
301303
302304 console . info ( "Function selected: " , selectedFunction . uid ) ;
303- ( async ( ) => {
304- setJobCollections ( [ ] ) ;
305- await updateJobCollections ( selectedFunction ?. uid as string ) ;
306- console . info ( "Updated JobCollections" ) ;
307- } ) ( ) ;
305+ handleJobsUpdate ( ) ;
308306 // eslint-disable-next-line react-hooks/exhaustive-deps
309307 } , [ selectedFunction ] ) ;
310308
0 commit comments