mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
* refactor: improve transcript list performance * fix: sync openapi * fix: frontend types * fix: remove drop table _alembic_tmp_meeting * fix: remove create table too * fix: remove uq_recording_object_key
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { useError } from "../../(errors)/errorContext";
|
|
import useApi from "../../lib/useApi";
|
|
import { Page_GetTranscriptMinimal_, SourceKind } from "../../api";
|
|
|
|
type TranscriptList = {
|
|
response: Page_GetTranscriptMinimal_ | null;
|
|
loading: boolean;
|
|
error: Error | null;
|
|
refetch: () => void;
|
|
};
|
|
|
|
const useTranscriptList = (
|
|
page: number,
|
|
sourceKind: SourceKind | null,
|
|
roomId: string | null,
|
|
searchTerm: string | null,
|
|
): TranscriptList => {
|
|
const [response, setResponse] = useState<Page_GetTranscriptMinimal_ | null>(
|
|
null,
|
|
);
|
|
const [loading, setLoading] = useState<boolean>(true);
|
|
const [error, setErrorState] = useState<Error | null>(null);
|
|
const { setError } = useError();
|
|
const api = useApi();
|
|
const [refetchCount, setRefetchCount] = useState(0);
|
|
|
|
const refetch = () => {
|
|
setLoading(true);
|
|
setRefetchCount(refetchCount + 1);
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (!api) return;
|
|
setLoading(true);
|
|
api
|
|
.v1TranscriptsList({
|
|
page,
|
|
sourceKind,
|
|
roomId,
|
|
searchTerm,
|
|
})
|
|
.then((response) => {
|
|
setResponse(response);
|
|
setLoading(false);
|
|
})
|
|
.catch((err) => {
|
|
setResponse(null);
|
|
setLoading(false);
|
|
setError(err);
|
|
setErrorState(err);
|
|
});
|
|
}, [!api, page, refetchCount, roomId, searchTerm]);
|
|
|
|
return { response, loading, error, refetch };
|
|
};
|
|
|
|
export default useTranscriptList;
|