@@ -31,7 +31,7 @@ import { Light as SyntaxHighlighter } from "react-syntax-highlighter"
3131import { vs } from "react-syntax-highlighter/dist/esm/styles/hljs"
3232import sql from "react-syntax-highlighter/dist/cjs/languages/hljs/sql"
3333import { useNavigate , useParams } from "react-router-dom"
34- import { useState , useEffect , useCallback } from "react"
34+ import { useState , useEffect , useCallback , useRef } from "react"
3535import { getApiUrl , headerBuilder } from '../api/config' ;
3636import BatchHistoryPanel from "../components/batchHistoryPanel"
3737import PanelRight from "../components/Panels/PanelRight" ;
@@ -497,6 +497,7 @@ const ModernizationPage = () => {
497497 const [ fileId , setFileId ] = React . useState < string > ( "" ) ;
498498 const [ expandedSections , setExpandedSections ] = React . useState < string [ ] > ( [ ] ) ;
499499 const [ allFilesCompleted , setAllFilesCompleted ] = useState ( false ) ;
500+ const [ progressPercentage , setProgressPercentage ] = useState ( 0 ) ;
500501 const [ isZipButtonDisabled , setIsZipButtonDisabled ] = useState ( true ) ;
501502 const [ fileLoading , setFileLoading ] = useState ( false ) ;
502503 const [ lastActivityTime , setLastActivityTime ] = useState < number > ( Date . now ( ) ) ;
@@ -514,18 +515,9 @@ const ModernizationPage = () => {
514515 if ( ! selectedFile || ! selectedFile . translatedCode ) {
515516 setFileLoading ( true ) ;
516517 const newFileUpdate = await fetchFileFromAPI ( selectedFile ?. fileId || "" ) ;
517- setFiles ( ( prevFiles ) =>
518- prevFiles . map ( ( file ) =>
519- file . fileId === selectedFile ?. fileId
520- ? {
521- ...file ,
522- code : newFileUpdate . content ,
523- translatedCode : newFileUpdate . translated_content ,
524- }
525- : file
526- )
527- ) ;
528518 setFileLoading ( false ) ;
519+ } else {
520+
529521 }
530522
531523 } catch ( err ) {
@@ -1013,16 +1005,16 @@ useEffect(() => {
10131005 } ;
10141006 } , [ handleWebSocketMessage ] ) ;
10151007
1016- // Set a timeout for initial loading - if still loading after 30 seconds, show a warning message
1008+ // Set a timeout for initial loading - if no progress after 30 seconds, show error
10171009 useEffect ( ( ) => {
10181010 const loadingTimeout = setTimeout ( ( ) => {
1019- if ( showLoading ) {
1011+ if ( progressPercentage < 5 && showLoading ) {
10201012 setLoadingError ( 'Processing is taking longer than expected. You can continue waiting or try again later.' ) ;
10211013 }
10221014 } , 30000 ) ;
10231015
10241016 return ( ) => clearTimeout ( loadingTimeout ) ;
1025- } , [ showLoading ] ) ;
1017+ } , [ progressPercentage , showLoading ] ) ;
10261018
10271019 // Add timeout mechanism to navigate if no activity for 30 seconds
10281020 useEffect ( ( ) => {
0 commit comments