| 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', |