Update CallPlayer.js

This commit is contained in:
Luke Berndt
2023-01-19 21:41:13 -05:00
parent 7f85f4079d
commit cb2a68a278

View File

@@ -27,6 +27,7 @@ import io from 'socket.io-client';
import { useCallLink } from "./components/CallLinks"; import { useCallLink } from "./components/CallLinks";
import "./CallPlayer.css"; import "./CallPlayer.css";
const socket = io(process.env.REACT_APP_BACKEND_SERVER); const socket = io(process.env.REACT_APP_BACKEND_SERVER);
@@ -119,8 +120,14 @@ function CallPlayer(props) {
} }
}, [loadOlderInView]); }, [loadOlderInView]);
// Triggered when a new call is selected in the parent component.
// This happens in 2 scenarios: when a call is specified in the URI or when a new call comes over the socket
// When a call is set to CurrentCall, it will automatically start playing
// we should only set the selectCallId to be the current call when AutoPlay is selected
// and when there isn't another call already playing
useEffect(() => { useEffect(() => {
if ( selectCallId && callsData ) { if ( selectCallId && callsData && !isPlaying && autoPlay) {
const call = callsData.entities[selectCallId]; const call = callsData.entities[selectCallId];
if (call) { if (call) {
setCurrentCall(call); setCurrentCall(call);