@@ -142,7 +142,6 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
142142
143143 useEffect ( ( ) => {
144144 if ( appStateContext . state ?. failedSections . length > 0 && appStateContext . state ?. failedSections [ 0 ] . title === sectionTitle && isLoading && ! appStateContext . state . isFailedReqInitiated ) {
145- console . log ( "appStateContext.state?.failedSections" , appStateContext . state ?. failedSections ) ;
146145 const tempItem = {
147146 title : sectionTitle ,
148147 description : sectionDescription ,
@@ -159,13 +158,13 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
159158 async function fetchSectionContent ( sectionTitle : string , sectionDescription : string , isReqFrom = '' ) {
160159 setIsLoading ( true )
161160 //onLoadingChange(true)
161+
162162 const sectionGenerateRequest : SectionGenerateRequest = { sectionTitle, sectionDescription }
163163
164164 const response = await sectionGenerate ( sectionGenerateRequest )
165165 const responseBody = await response . json ( )
166166
167167 if ( responseBody ?. error ?. includes ( "429" ) ) {
168- console . log ( "retriggerd !!!" )
169168 const failedSectionItems = {
170169 title : sectionTitle ,
171170 description : sectionDescription ,
@@ -212,6 +211,11 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
212211 useEffect ( ( ) => {
213212 if ( sectionContent === '' && ! isLoading && ! isManuallyCleared ) {
214213 fetchSectionContent ( sectionTitle , sectionDescription )
214+ } else {
215+ if ( sectionContent != '' && ! isLoading ) {
216+ const updatedSection : Section = { ...section }
217+ appStateContext ?. dispatch ( { type : 'UPDATE_IS_LOADED_SECTIONS' , payload : { section : updatedSection } } )
218+ }
215219 }
216220 } , [ sectionContent , isLoading , isManuallyCleared ] )
217221
@@ -261,6 +265,7 @@ const SectionCard = ({ sectionIdx }: SectionCardProps) => {
261265 console . error ( 'Section description is empty' )
262266 return
263267 }
268+ appStateContext ?. dispatch ( { type : 'UPDATE_IS_LOADED_SECTIONS' , payload : { section : null , 'title' : sectionTitle , 'act' :'removeItem' } } )
264269
265270 setIsPopoverOpen ( false )
266271 fetchSectionContent ( sectionTitle , updatedSectionDescription )
0 commit comments