Browse Source

fix: status query not stop when leaving document embedding detail page (#4754)

tags/0.6.10
doufa 1 year ago
parent
commit
b1c9671a60
No account linked to committer's email address
1 changed files with 10 additions and 14 deletions
  1. 10
    14
      web/app/components/datasets/documents/detail/embedding/index.tsx

+ 10
- 14
web/app/components/datasets/documents/detail/embedding/index.tsx View File

return status return status
} }


const [isStopQuery, setIsStopQuery] = useState(false)
const isStopQueryRef = useRef(isStopQuery)
useEffect(() => {
isStopQueryRef.current = isStopQuery
}, [isStopQuery])
const stopQueryStatus = () => {
setIsStopQuery(true)
}
const isStopQuery = useRef(false)
const stopQueryStatus = useCallback(() => {
isStopQuery.current = true
}, [])


const startQueryStatus = async () => {
if (isStopQueryRef.current)
const startQueryStatus = useCallback(async () => {
if (isStopQuery.current)
return return


try { try {
detailUpdate() detailUpdate()
return return
} }

await sleep(2500) await sleep(2500)
await startQueryStatus() await startQueryStatus()
} }
await sleep(2500) await sleep(2500)
await startQueryStatus() await startQueryStatus()
} }
}
}, [stopQueryStatus])


useEffect(() => { useEffect(() => {
setIsStopQuery(false)
isStopQuery.current = false
startQueryStatus() startQueryStatus()
return () => { return () => {
stopQueryStatus() stopQueryStatus()
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
}, [startQueryStatus, stopQueryStatus])


const { data: indexingEstimateDetail, error: indexingEstimateErr } = useSWR({ const { data: indexingEstimateDetail, error: indexingEstimateErr } = useSWR({
action: 'fetchIndexingEstimate', action: 'fetchIndexingEstimate',

Loading…
Cancel
Save