From dfae44d861c7be512d050f0f2ae726047f536604 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 15 Jan 2023 09:56:25 -0500 Subject: [PATCH] really really working now --- frontend/src/Call/CallPlayer.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/Call/CallPlayer.js b/frontend/src/Call/CallPlayer.js index b794f64..fb8b13e 100644 --- a/frontend/src/Call/CallPlayer.js +++ b/frontend/src/Call/CallPlayer.js @@ -70,8 +70,8 @@ function CallPlayer(props) { const navigate = useNavigate(); const dispatch = useDispatch(); const positionRef = useRef(); - const isPlayingRef = useRef(); // we need to do this to make the current value of isPlaying available in the socket message callback - isPlayingRef.current = isPlaying; + const shouldPlayAddCallRef = useRef(); // we need to do this to make the current value of isPlaying available in the socket message callback + shouldPlayAddCallRef.current = (!isPlaying && autoPlay)?true:false; const filterType = useSelector((state) => state.callPlayer.filterType); const filterGroupId = useSelector((state) => state.callPlayer.filterGroupId); @@ -156,11 +156,11 @@ function CallPlayer(props) { const message = JSON.parse(data) switch (message.type) { case 'calls': - const ref = positionRef; - setPrevScrollHeight(positionRef.clientHeight); + const ref = positionRef.current; + setPrevScrollHeight(positionRef.current.clientHeight); setAddCallScroll(true); - if (!isPlayingRef.current) { + if (shouldPlayAddCallRef.current) { setCurrentCall(message); } @@ -342,8 +342,8 @@ function CallPlayer(props) { useEffect(() => { if (addCallScroll) { - const ref = positionRef; - window.scrollBy(0, positionRef.clientHeight - prevScrollHeight); + const ref = positionRef.current; + window.scrollBy(0, positionRef.current.clientHeight - prevScrollHeight); setAddCallScroll(false); } if (selectLoadCall && loadCallId && callsData) {