fix: resume translation polling when returning to task detail page
Add useEffect to check for in-progress translations on page load. This ensures that if user navigates away during translation and returns, the UI will resume polling and show completion status. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,32 @@ export default function TaskDetailPage() {
|
|||||||
retry: false,
|
retry: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Check for in-progress translation on page load
|
||||||
|
useEffect(() => {
|
||||||
|
if (!taskId || !taskDetail || taskDetail.status !== 'completed') return
|
||||||
|
|
||||||
|
const checkTranslationStatus = async () => {
|
||||||
|
try {
|
||||||
|
const status = await apiClientV2.getTranslationStatus(taskId)
|
||||||
|
if (status.status === 'translating' || status.status === 'pending') {
|
||||||
|
// Resume polling for in-progress translation
|
||||||
|
setIsTranslating(true)
|
||||||
|
setTranslationStatus(status.status)
|
||||||
|
if (status.progress) {
|
||||||
|
setTranslationProgress(status.progress.percentage)
|
||||||
|
}
|
||||||
|
if (status.target_lang) {
|
||||||
|
setTargetLang(status.target_lang)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// No active translation job - this is normal
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkTranslationStatus()
|
||||||
|
}, [taskId, taskDetail])
|
||||||
|
|
||||||
// Poll translation status when translating
|
// Poll translation status when translating
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isTranslating || !taskId) return
|
if (!isTranslating || !taskId) return
|
||||||
|
|||||||
Reference in New Issue
Block a user