From bc0911d2473f4fa7ab8d36f512724098c44d4d05 Mon Sep 17 00:00:00 2001 From: harshithpabbati Date: Fri, 8 Apr 2022 12:52:46 +0530 Subject: [PATCH] fix track subscription error --- custom/shared/contexts/TracksProvider.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom/shared/contexts/TracksProvider.js b/custom/shared/contexts/TracksProvider.js index d4f17e5..83b2068 100644 --- a/custom/shared/contexts/TracksProvider.js +++ b/custom/shared/contexts/TracksProvider.js @@ -32,7 +32,7 @@ const SUBSCRIBE_OR_STAGE_ALL_VIDEO_THRESHOLD = 9; const TracksContext = createContext(null); export const TracksProvider = ({ children }) => { - const { callObject: daily, optimizeLargeCalls } = useCallState(); + const { callObject: daily, optimizeLargeCalls, subscribeToTracksAutomatically } = useCallState(); const { participants } = useParticipants(); const { viewMode } = useUIState(); const [state, dispatch] = useReducer(tracksReducer, initialTracksState); @@ -327,7 +327,8 @@ export const TracksProvider = ({ children }) => { const joinedSubscriptionQueue = useRef([]); useEffect(() => { - if (!daily) return; + if (!daily || subscribeToTracksAutomatically) return; + const joinBatchInterval = setInterval(async () => { if (!joinedSubscriptionQueue.current.length) return; const ids = joinedSubscriptionQueue.current.splice(0); @@ -356,7 +357,7 @@ export const TracksProvider = ({ children }) => { return () => { clearInterval(joinBatchInterval); }; - }, [daily]); + }, [daily, subscribeToTracksAutomatically]); useEffect(() => { if (optimizeLargeCalls) {