mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-22 13:19: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,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import Peer from "simple-peer";
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
import useApi from "../../lib/useApi";
|
||||
import { useTranscriptWebRTC } from "../../lib/api-hooks";
|
||||
import { RtcOffer } from "../../lib/api-types";
|
||||
|
||||
const useWebRTC = (
|
||||
@@ -10,10 +10,10 @@ const useWebRTC = (
|
||||
): Peer => {
|
||||
const [peer, setPeer] = useState<Peer | null>(null);
|
||||
const { setError } = useError();
|
||||
const api = useApi();
|
||||
const webRTCMutation = useTranscriptWebRTC();
|
||||
|
||||
useEffect(() => {
|
||||
if (!stream || !transcriptId || !api) {
|
||||
if (!stream || !transcriptId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const useWebRTC = (
|
||||
try {
|
||||
p = new Peer({ initiator: true, stream: stream });
|
||||
} catch (error) {
|
||||
setError(error, "Error creating WebRTC");
|
||||
setError(error as Error, "Error creating WebRTC");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,26 +32,31 @@ const useWebRTC = (
|
||||
setError(new Error(`WebRTC error: ${err}`));
|
||||
});
|
||||
|
||||
p.on("signal", (data: any) => {
|
||||
if (!api) return;
|
||||
p.on("signal", async (data: any) => {
|
||||
if ("sdp" in data) {
|
||||
const rtcOffer: RtcOffer = {
|
||||
sdp: data.sdp,
|
||||
type: data.type,
|
||||
};
|
||||
|
||||
api
|
||||
.v1TranscriptRecordWebrtc({ transcriptId, requestBody: rtcOffer })
|
||||
.then((answer) => {
|
||||
try {
|
||||
p.signal(answer);
|
||||
} catch (error) {
|
||||
setError(error);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
setError(error, "Error loading WebRTCOffer");
|
||||
try {
|
||||
const answer = await webRTCMutation.mutateAsync({
|
||||
params: {
|
||||
path: {
|
||||
transcript_id: transcriptId,
|
||||
},
|
||||
},
|
||||
body: rtcOffer,
|
||||
});
|
||||
|
||||
try {
|
||||
p.signal(answer);
|
||||
} catch (error) {
|
||||
setError(error as Error);
|
||||
}
|
||||
} catch (error) {
|
||||
setError(error as Error, "Error loading WebRTCOffer");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,7 +68,7 @@ const useWebRTC = (
|
||||
return () => {
|
||||
p.destroy();
|
||||
};
|
||||
}, [stream, transcriptId, !api]);
|
||||
}, [stream, transcriptId, webRTCMutation]);
|
||||
|
||||
return peer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user