Skip to content

Commit 5d63b3e

Browse files
authored
Revert "fix(revert): ensure the call is joined before notifying readiness (#2…"
This reverts commit 1d6bf19.
1 parent 399dd1a commit 5d63b3e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sample-apps/react/egress-composite/src/hooks/useNotifyEgress.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
useEffect,
77
useState,
88
} from 'react';
9+
import { CallingState, useCallStateHooks } from '@stream-io/video-react-sdk';
910

1011
const EgressReadyNotificationContext = createContext((isReady: boolean) => {
1112
// no-op
@@ -14,10 +15,13 @@ const EgressReadyNotificationContext = createContext((isReady: boolean) => {
1415

1516
export const EgressReadyNotificationProvider = (props: PropsWithChildren) => {
1617
const [isReady, setIsReady] = useState(false);
18+
const { useCallCallingState } = useCallStateHooks();
19+
const callingState = useCallCallingState();
1720
useEffect(() => {
18-
if (isReady) return;
21+
if (isReady || callingState !== CallingState.JOINED) return;
1922
// it could happen that components won't notify us that they are ready
2023
// in that case, we start recording anyway after 4 seconds.
24+
console.log('Egress: Started waiting for components to notify readiness');
2125
const timeout = setTimeout(() => {
2226
if (!isReady) {
2327
console.log('Timeout: Egress is ready');
@@ -28,7 +32,7 @@ export const EgressReadyNotificationProvider = (props: PropsWithChildren) => {
2832
return () => {
2933
clearTimeout(timeout);
3034
};
31-
}, [isReady]);
35+
}, [callingState, isReady]);
3236

3337
const spyIsReady = useCallback((value: boolean) => {
3438
setIsReady((current) => {

0 commit comments

Comments
 (0)