mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 13:19:05 +00:00
start participants, fix selection
This commit is contained in:
@@ -23,16 +23,30 @@ type SuccessTopicWithWords = {
|
||||
error: null;
|
||||
};
|
||||
|
||||
type UseTopicWithWords = { refetch: () => void } & (
|
||||
| ErrorTopicWithWords
|
||||
| LoadingTopicWithWords
|
||||
| SuccessTopicWithWords
|
||||
);
|
||||
|
||||
const useTopicWithWords = (
|
||||
topicId: string | null,
|
||||
transcriptId: string,
|
||||
): ErrorTopicWithWords | LoadingTopicWithWords | SuccessTopicWithWords => {
|
||||
): UseTopicWithWords => {
|
||||
const [response, setResponse] = useState<GetTranscript | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [error, setErrorState] = useState<Error | null>(null);
|
||||
const { setError } = useError();
|
||||
const api = getApi();
|
||||
|
||||
const [count, setCount] = useState(0);
|
||||
|
||||
const refetch = () => {
|
||||
setCount(count + 1);
|
||||
setLoading(true);
|
||||
setErrorState(null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
}, [transcriptId, topicId]);
|
||||
@@ -60,12 +74,9 @@ const useTopicWithWords = (
|
||||
}
|
||||
setErrorState(error);
|
||||
});
|
||||
}, [transcriptId, !api, topicId]);
|
||||
}, [transcriptId, !api, topicId, count]);
|
||||
|
||||
return { response, loading, error } as
|
||||
| ErrorTopicWithWords
|
||||
| LoadingTopicWithWords
|
||||
| SuccessTopicWithWords;
|
||||
return { response, loading, error, refetch } as UseTopicWithWords;
|
||||
};
|
||||
|
||||
export default useTopicWithWords;
|
||||
|
||||
Reference in New Issue
Block a user