mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Fixed setError/useError typos & added stronger typing
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
|
||||
const handleError = (
|
||||
setError: Function,
|
||||
setError: Dispatch<SetStateAction<String>>,
|
||||
errorString: string,
|
||||
errorObj?: any,
|
||||
) => {
|
||||
|
||||
@@ -9,7 +9,6 @@ import useAudioDevice from "../useAudioDevice";
|
||||
import "../../styles/button.css";
|
||||
import { Topic } from "../webSocketTypes";
|
||||
import getApi from "../../lib/getApi";
|
||||
import { useError } from "../../(errors)/errorContext";
|
||||
|
||||
const App = () => {
|
||||
const [stream, setStream] = useState<MediaStream | null>(null);
|
||||
|
||||
@@ -108,13 +108,13 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
||||
default:
|
||||
console.error("Unknown event:", message.event);
|
||||
handleError(
|
||||
useError,
|
||||
setError,
|
||||
`Received unknown WebSocket event: ${message.event}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
handleError(
|
||||
useError,
|
||||
setError,
|
||||
`Failed to process WebSocket message: ${error.message}`,
|
||||
error,
|
||||
);
|
||||
@@ -123,14 +123,14 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
||||
|
||||
ws.onerror = (error) => {
|
||||
console.error("WebSocket error:", error);
|
||||
handleError(useError, "A WebSocket error occurred.", error);
|
||||
handleError(setError, "A WebSocket error occurred.", error);
|
||||
};
|
||||
|
||||
ws.onclose = (event) => {
|
||||
console.debug("WebSocket connection closed");
|
||||
if (event.code !== 1000) {
|
||||
handleError(
|
||||
useError,
|
||||
setError,
|
||||
`WebSocket closed unexpectedly with code: ${event.code}`,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user