|
|
@@ -1,6 +1,5 @@
|
|
|
-import React, { useCallback, useEffect, useState } from 'react'
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
|
import PropTypes from 'prop-types'
|
|
|
-import AbortController from 'abort-controller'
|
|
|
import WordCountModalContent from './word-count-modal-content'
|
|
|
import { fetchWordCount } from '../utils/api'
|
|
|
|
|
|
@@ -8,7 +7,6 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|
|
const [loading, setLoading] = useState(true)
|
|
|
const [error, setError] = useState(false)
|
|
|
const [data, setData] = useState()
|
|
|
- const [abortController, setAbortController] = useState(new AbortController())
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (!show) {
|
|
|
@@ -19,12 +17,7 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|
|
setError(false)
|
|
|
setLoading(true)
|
|
|
|
|
|
- const _abortController = new AbortController()
|
|
|
- setAbortController(_abortController)
|
|
|
-
|
|
|
- fetchWordCount(projectId, clsiServerId, {
|
|
|
- signal: _abortController.signal
|
|
|
- })
|
|
|
+ fetchWordCount(projectId, clsiServerId)
|
|
|
.then(data => {
|
|
|
setData(data.texcount)
|
|
|
})
|
|
|
@@ -36,23 +29,14 @@ function WordCountModal({ clsiServerId, handleHide, projectId, show }) {
|
|
|
.finally(() => {
|
|
|
setLoading(false)
|
|
|
})
|
|
|
-
|
|
|
- return () => {
|
|
|
- _abortController.abort()
|
|
|
- }
|
|
|
}, [show, projectId, clsiServerId])
|
|
|
|
|
|
- const abortAndHide = useCallback(() => {
|
|
|
- abortController.abort()
|
|
|
- handleHide()
|
|
|
- }, [abortController, handleHide])
|
|
|
-
|
|
|
return (
|
|
|
<WordCountModalContent
|
|
|
data={data}
|
|
|
error={error}
|
|
|
show={show}
|
|
|
- handleHide={abortAndHide}
|
|
|
+ handleHide={handleHide}
|
|
|
loading={loading}
|
|
|
/>
|
|
|
)
|