no need to stop from server

This commit is contained in:
Jose B
2023-07-27 19:42:09 -05:00
parent f17d996f39
commit e68b6ced11
3 changed files with 4 additions and 5 deletions

View File

@@ -89,7 +89,7 @@ export default function Recorder(props) {
const handleRecClick = async () => {
if (!record) return console.log("no record");
if (record?.isRecording()) {
if (record.isRecording()) {
props.onStop();
record.stopRecording();
setIsRecording(false);

View File

@@ -3,7 +3,7 @@ import Peer from "simple-peer";
const WebRTC_SERVER_URL = "http://127.0.0.1:1250/offer";
const useWebRTC = (stream, setIsRecording) => {
const useWebRTC = (stream) => {
const [data, setData] = useState({
peer: null,
});
@@ -66,7 +66,6 @@ const useWebRTC = (stream, setIsRecording) => {
},
text: ''
}));
setIsRecording(false);
break;
default:
console.error(`Unknown command ${serverData.cmd}`);
@@ -76,7 +75,7 @@ const useWebRTC = (stream, setIsRecording) => {
return () => {
peer.destroy();
};
}, [stream, setIsRecording]);
}, [stream]);
return data;
};

View File

@@ -10,7 +10,7 @@ const App = () => {
// This is where you'd send the stream and receive the data from the server.
// transcription, summary, etc
const serverData = useWebRTC(stream, () => { });
const serverData = useWebRTC(stream);
const sendStopCmd = () => serverData?.peer?.send(JSON.stringify({ cmd: "STOP" }))