Skip to content

Commit dd5d8f8

Browse files
authored
fix: open fg service only on a successful join (#1666)
Joining can fail due to permission errors, so open FG service only on successful join
1 parent 36a9683 commit dd5d8f8

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

packages/react-native-sdk/src/hooks/useAndroidKeepCallAliveEffect.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getNotifeeLibNoThrowForKeepCallAlive,
88
getKeepCallAliveForegroundServiceTypes,
99
} from '../utils/push/libs/notifee';
10-
import { usePrevious } from '../utils/hooks';
1110

1211
const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive();
1312

@@ -86,23 +85,12 @@ export const useAndroidKeepCallAliveEffect = () => {
8685
const { useCallCallingState } = useCallStateHooks();
8786
const callingState = useCallCallingState();
8887

89-
const prevCallingState = usePrevious(callingState);
90-
91-
const isStartingToJoin =
92-
prevCallingState === CallingState.IDLE &&
93-
callingState === CallingState.JOINING;
94-
const isStartingToJoinFromRinging =
95-
prevCallingState === CallingState.RINGING &&
96-
callingState === CallingState.JOINING;
9788
const isOutgoingCall =
9889
callingState === CallingState.RINGING && call?.isCreatedByMe;
9990
const isCallJoined = callingState === CallingState.JOINED;
10091

10192
const shouldStartForegroundService =
102-
isStartingToJoin ||
103-
isStartingToJoinFromRinging ||
104-
isOutgoingCall ||
105-
isCallJoined;
93+
!foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined);
10694

10795
useEffect((): (() => void) | undefined => {
10896
if (Platform.OS === 'ios' || !activeCallCid) {

0 commit comments

Comments
 (0)