prevent double action

This commit is contained in:
Sara
2023-12-12 15:18:22 +01:00
parent 89dfda29a5
commit 5e7eeb8f24
6 changed files with 126 additions and 86 deletions

View File

@@ -42,7 +42,7 @@ const useTopicWithWords = (
): UseTopicWithWords => {
const [response, setResponse] =
useState<GetTranscriptTopicWithWordsPerSpeaker | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [loading, setLoading] = useState<boolean>(false);
const [error, setErrorState] = useState<Error | null>(null);
const { setError } = useError();
const api = getApi();
@@ -50,15 +50,13 @@ const useTopicWithWords = (
const [count, setCount] = useState(0);
const refetch = () => {
setCount(count + 1);
setLoading(true);
setErrorState(null);
if (!loading) {
setCount(count + 1);
setLoading(true);
setErrorState(null);
}
};
useEffect(() => {
setLoading(true);
}, [transcriptId, topicId]);
useEffect(() => {
if (!transcriptId || !topicId || !api) return;