www: fix loading of past transcript before the user is authenticated

This commit is contained in:
2023-10-24 20:23:10 +02:00
committed by Mathieu Virbel
parent 220b9811af
commit 93ba1b450c
5 changed files with 31 additions and 29 deletions

View File

@@ -13,15 +13,14 @@ type TranscriptTopics = {
error: Error | null;
};
const useTranscript = (api: DefaultApi, id: string): TranscriptTopics => {
const useTopics = (api: DefaultApi, id: string): TranscriptTopics => {
const [topics, setTopics] = useState<Topic[] | null>(null);
const [loading, setLoading] = useState<boolean>(false);
const [error, setErrorState] = useState<Error | null>(null);
const { setError } = useError();
const getTopics = (id: string) => {
if (!id)
throw new Error("Transcript ID is required to get transcript topics");
if (!id) return;
setLoading(true);
const requestParameters: V1TranscriptGetTopicsRequest = {
@@ -47,4 +46,4 @@ const useTranscript = (api: DefaultApi, id: string): TranscriptTopics => {
return { topics, loading, error };
};
export default useTranscript;
export default useTopics;