Fixed all linting errors
This commit is contained in:
parent
eb12d95bc5
commit
dd8efe4a02
@ -174,7 +174,7 @@ const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
|||||||
getLobby(lobbyName, session).finally(() => {
|
getLobby(lobbyName, session).finally(() => {
|
||||||
setCreatingLobby(false);
|
setCreatingLobby(false);
|
||||||
});
|
});
|
||||||
}, [session, lobbyName, lobby, setLobby, setError]);
|
}, [session, lobbyName, lobby, setLobby, setError, creatingLobby]);
|
||||||
const setName = (name: string) => {
|
const setName = (name: string) => {
|
||||||
sendJsonMessage({
|
sendJsonMessage({
|
||||||
type: "set_name",
|
type: "set_name",
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
import React, { useState, useEffect, useRef, KeyboardEvent } from "react";
|
import React, { useState, useEffect, useRef, KeyboardEvent } from "react";
|
||||||
import {
|
import { Paper, TextField, List, ListItem, ListItemText, Typography, Box, IconButton } from "@mui/material";
|
||||||
Paper,
|
|
||||||
TextField,
|
|
||||||
Button,
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemText,
|
|
||||||
Typography,
|
|
||||||
Box,
|
|
||||||
IconButton,
|
|
||||||
} from "@mui/material";
|
|
||||||
import SendIcon from "@mui/icons-material/Send";
|
import SendIcon from "@mui/icons-material/Send";
|
||||||
import useWebSocket from "react-use-websocket";
|
import useWebSocket from "react-use-websocket";
|
||||||
import { Session } from "./GlobalContext";
|
import { Session } from "./GlobalContext";
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import React, { useState, useEffect, useRef, useCallback } from "react";
|
import React, { useState, useEffect, useRef, useCallback } from "react";
|
||||||
import Moveable from "react-moveable";
|
|
||||||
import { flushSync } from "react-dom";
|
|
||||||
import "./MediaControl.css";
|
import "./MediaControl.css";
|
||||||
import VolumeOff from "@mui/icons-material/VolumeOff";
|
import VolumeOff from "@mui/icons-material/VolumeOff";
|
||||||
import VolumeUp from "@mui/icons-material/VolumeUp";
|
import VolumeUp from "@mui/icons-material/VolumeUp";
|
||||||
@ -333,19 +331,22 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
const pendingIceCandidatesRef = useRef<Map<string, RTCIceCandidateInit[]>>(new Map());
|
const pendingIceCandidatesRef = useRef<Map<string, RTCIceCandidateInit[]>>(new Map());
|
||||||
|
|
||||||
// Update peer states when connection state changes
|
// Update peer states when connection state changes
|
||||||
const updatePeerConnectionState = useCallback((peerId: string, connectionState: string, isNegotiating: boolean = false) => {
|
const updatePeerConnectionState = useCallback(
|
||||||
setPeers(prevPeers => {
|
(peerId: string, connectionState: string, isNegotiating: boolean = false) => {
|
||||||
const updatedPeers = { ...prevPeers };
|
setPeers((prevPeers) => {
|
||||||
if (updatedPeers[peerId]) {
|
const updatedPeers = { ...prevPeers };
|
||||||
updatedPeers[peerId] = {
|
if (updatedPeers[peerId]) {
|
||||||
...updatedPeers[peerId],
|
updatedPeers[peerId] = {
|
||||||
connectionState,
|
...updatedPeers[peerId],
|
||||||
isNegotiating
|
connectionState,
|
||||||
};
|
isNegotiating,
|
||||||
}
|
};
|
||||||
return updatedPeers;
|
}
|
||||||
});
|
return updatedPeers;
|
||||||
}, [setPeers]);
|
});
|
||||||
|
},
|
||||||
|
[setPeers]
|
||||||
|
);
|
||||||
|
|
||||||
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
|
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
|
||||||
share: true,
|
share: true,
|
||||||
@ -410,7 +411,6 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
// Queue peer if we need local media but don't have it yet
|
// Queue peer if we need local media but don't have it yet
|
||||||
// Only queue if we're expected to provide media (local user has media)
|
// Only queue if we're expected to provide media (local user has media)
|
||||||
const localUserHasMedia = session?.has_media !== false; // Default to true for backward compatibility
|
const localUserHasMedia = session?.has_media !== false; // Default to true for backward compatibility
|
||||||
const peerHasMedia = config.has_media !== false; // Default to true for backward compatibility
|
|
||||||
|
|
||||||
// Only need to wait for media if we (local user) are supposed to provide it
|
// Only need to wait for media if we (local user) are supposed to provide it
|
||||||
if (!media && localUserHasMedia) {
|
if (!media && localUserHasMedia) {
|
||||||
@ -730,7 +730,7 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[peers, setPeers, media, sendJsonMessage]
|
[peers, setPeers, media, sendJsonMessage, session?.has_media, updatePeerConnectionState]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Process queued peers when media becomes available
|
// Process queued peers when media becomes available
|
||||||
@ -826,7 +826,7 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[peers, sendJsonMessage]
|
[peers, sendJsonMessage, updatePeerConnectionState]
|
||||||
);
|
);
|
||||||
|
|
||||||
const removePeer = useCallback(
|
const removePeer = useCallback(
|
||||||
@ -1074,6 +1074,9 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
|
|
||||||
if (mediaStreamRef.current || readyState !== ReadyState.OPEN) return;
|
if (mediaStreamRef.current || readyState !== ReadyState.OPEN) return;
|
||||||
|
|
||||||
|
// Capture the connections at effect setup time
|
||||||
|
const connectionsToCleanup = connectionsRef.current;
|
||||||
|
|
||||||
if (localUserHasMedia) {
|
if (localUserHasMedia) {
|
||||||
console.log(`media-agent - Setting up local media`);
|
console.log(`media-agent - Setting up local media`);
|
||||||
setup_local_media().then((mediaStream) => {
|
setup_local_media().then((mediaStream) => {
|
||||||
@ -1111,9 +1114,9 @@ const MediaAgent = (props: MediaAgentProps) => {
|
|||||||
mediaStreamRef.current = null;
|
mediaStreamRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up connections
|
// Clean up connections using the captured ref value
|
||||||
connectionsRef.current.forEach((connection) => connection.close());
|
connectionsToCleanup.forEach((connection) => connection.close());
|
||||||
connectionsRef.current.clear();
|
connectionsToCleanup.clear();
|
||||||
};
|
};
|
||||||
}, [readyState, setup_local_media, session]);
|
}, [readyState, setup_local_media, session]);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// TypeScript API client for AI Voicebot server
|
// TypeScript API client for AI Voicebot server
|
||||||
import { components, paths } from "./api-types";
|
import { components } from "./api-types";
|
||||||
import { base } from "./Common";
|
import { base } from "./Common";
|
||||||
|
|
||||||
// Re-export commonly used types from the generated schema
|
// Re-export commonly used types from the generated schema
|
||||||
|
Loading…
x
Reference in New Issue
Block a user