mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-13 19:08:15 +08:00
fix: status query not stop when leaving document embedding detail page (#4754)
This commit is contained in:
parent
7aaa1ff270
commit
b1c9671a60
@ -126,17 +126,13 @@ const EmbeddingDetail: FC<Props> = ({ detail, stopPosition = 'top', datasetId: d
|
|||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
const [isStopQuery, setIsStopQuery] = useState(false)
|
const isStopQuery = useRef(false)
|
||||||
const isStopQueryRef = useRef(isStopQuery)
|
const stopQueryStatus = useCallback(() => {
|
||||||
useEffect(() => {
|
isStopQuery.current = true
|
||||||
isStopQueryRef.current = isStopQuery
|
}, [])
|
||||||
}, [isStopQuery])
|
|
||||||
const stopQueryStatus = () => {
|
|
||||||
setIsStopQuery(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
const startQueryStatus = async () => {
|
const startQueryStatus = useCallback(async () => {
|
||||||
if (isStopQueryRef.current)
|
if (isStopQuery.current)
|
||||||
return
|
return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -146,6 +142,7 @@ const EmbeddingDetail: FC<Props> = ({ detail, stopPosition = 'top', datasetId: d
|
|||||||
detailUpdate()
|
detailUpdate()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await sleep(2500)
|
await sleep(2500)
|
||||||
await startQueryStatus()
|
await startQueryStatus()
|
||||||
}
|
}
|
||||||
@ -153,16 +150,15 @@ const EmbeddingDetail: FC<Props> = ({ detail, stopPosition = 'top', datasetId: d
|
|||||||
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…
x
Reference in New Issue
Block a user