From e2f1f6564e0dfd2535736cfa62c2e69044cf6490 Mon Sep 17 00:00:00 2001 From: Santhosh Vaiyapuri Date: Fri, 31 Jan 2025 06:59:46 +0100 Subject: [PATCH] fix: open fg service only on a successful join --- .../src/hooks/useAndroidKeepCallAliveEffect.ts | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/packages/react-native-sdk/src/hooks/useAndroidKeepCallAliveEffect.ts b/packages/react-native-sdk/src/hooks/useAndroidKeepCallAliveEffect.ts index bd8bc7cebe..2290b02e9f 100644 --- a/packages/react-native-sdk/src/hooks/useAndroidKeepCallAliveEffect.ts +++ b/packages/react-native-sdk/src/hooks/useAndroidKeepCallAliveEffect.ts @@ -7,7 +7,6 @@ import { getNotifeeLibNoThrowForKeepCallAlive, getKeepCallAliveForegroundServiceTypes, } from '../utils/push/libs/notifee'; -import { usePrevious } from '../utils/hooks'; const notifeeLib = getNotifeeLibNoThrowForKeepCallAlive(); @@ -86,23 +85,12 @@ export const useAndroidKeepCallAliveEffect = () => { const { useCallCallingState } = useCallStateHooks(); const callingState = useCallCallingState(); - const prevCallingState = usePrevious(callingState); - - const isStartingToJoin = - prevCallingState === CallingState.IDLE && - callingState === CallingState.JOINING; - const isStartingToJoinFromRinging = - prevCallingState === CallingState.RINGING && - callingState === CallingState.JOINING; const isOutgoingCall = callingState === CallingState.RINGING && call?.isCreatedByMe; const isCallJoined = callingState === CallingState.JOINED; const shouldStartForegroundService = - isStartingToJoin || - isStartingToJoinFromRinging || - isOutgoingCall || - isCallJoined; + !foregroundServiceStartedRef.current && (isOutgoingCall || isCallJoined); useEffect((): (() => void) | undefined => { if (Platform.OS === 'ios' || !activeCallCid) {