mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 21:29:05 +00:00
feat: complete migration from @hey-api/openapi-ts to openapi-react-query
- Migrated all components from useApi compatibility layer to direct React Query hooks - Added new hooks for participant operations, room meetings, and speaker operations - Updated all imports from old api module to api-types - Fixed TypeScript types and API endpoint signatures - Removed deprecated useApi.ts compatibility layer - Fixed SourceKind enum values to match OpenAPI spec - Added @ts-ignore for Zulip endpoints not in OpenAPI spec yet - Fixed all compilation errors and type issues
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { AudioWaveform } from "../../lib/api-types";
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
import useApi from "../../lib/useApi";
|
||||
import { shouldShowError } from "../../lib/errorUtils";
|
||||
import { useTranscriptWaveform } from "../../lib/api-hooks";
|
||||
|
||||
type AudioWaveFormResponse = {
|
||||
waveform: AudioWaveform | null;
|
||||
@@ -11,35 +8,17 @@ type AudioWaveFormResponse = {
|
||||
};
|
||||
|
||||
const useWaveform = (id: string, skip: boolean): AudioWaveFormResponse => {
|
||||
const [waveform, setWaveform] = useState<AudioWaveform | null>(null);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [error, setErrorState] = useState<Error | null>(null);
|
||||
const { setError } = useError();
|
||||
const api = useApi();
|
||||
const {
|
||||
data: waveform,
|
||||
isLoading: loading,
|
||||
error,
|
||||
} = useTranscriptWaveform(skip ? null : id);
|
||||
|
||||
useEffect(() => {
|
||||
if (!id || !api || skip) {
|
||||
setLoading(false);
|
||||
setErrorState(null);
|
||||
setWaveform(null);
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
setErrorState(null);
|
||||
api
|
||||
.v1TranscriptGetAudioWaveform({ transcriptId: id })
|
||||
.then((result) => {
|
||||
setWaveform(result);
|
||||
setLoading(false);
|
||||
console.debug("Transcript waveform loaded:", result);
|
||||
})
|
||||
.catch((err) => {
|
||||
setErrorState(err);
|
||||
setLoading(false);
|
||||
});
|
||||
}, [id, api, skip]);
|
||||
|
||||
return { waveform, loading, error };
|
||||
return {
|
||||
waveform: waveform || null,
|
||||
loading,
|
||||
error: error as Error | null,
|
||||
};
|
||||
};
|
||||
|
||||
export default useWaveform;
|
||||
|
||||
Reference in New Issue
Block a user