Skip to content

Commit 36ed84f

Browse files
committed
chore(voip): document iOS busy-call helpers; tighten videoconf guard tests
Document why hasActiveCall() and rejectBusyCall() are not used from AppDelegate during CallKit call-waiting, and type voipBlocksIncomingVideoconf tests with IClientMediaCall instead of any. Made-with: Cursor
1 parent 4a0e2f7 commit 36ed84f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

app/lib/services/voip/voipBlocksIncomingVideoconf.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import type { IClientMediaCall } from '@rocket.chat/media-signaling';
2+
13
import { voipBlocksIncomingVideoconf } from './voipBlocksIncomingVideoconf';
24

3-
const mockGetState = jest.fn(() => ({
4-
call: null as unknown,
5-
nativeAcceptedCallId: null as string | null
5+
type CallStoreSlice = {
6+
call: IClientMediaCall | null;
7+
nativeAcceptedCallId: string | null;
8+
};
9+
10+
const mockGetState = jest.fn((): CallStoreSlice => ({
11+
call: null,
12+
nativeAcceptedCallId: null
613
}));
714

815
jest.mock('./useCallStore', () => ({
@@ -21,8 +28,9 @@ describe('voipBlocksIncomingVideoconf', () => {
2128
});
2229

2330
it('returns true when VoIP store has an active call', () => {
31+
const activeCall = { callId: 'voip-1' } as unknown as IClientMediaCall;
2432
mockGetState.mockReturnValue({
25-
call: { callId: 'voip-1' } as any,
33+
call: activeCall,
2634
nativeAcceptedCallId: null
2735
});
2836
expect(voipBlocksIncomingVideoconf()).toBe(true);

ios/Libraries/VoipService.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public final class VoipService: NSObject {
139139

140140
/// Returns `true` when CXCallObserver reports any non-ended call (ringing or connected),
141141
/// including phone, FaceTime, and third-party VoIP.
142+
///
143+
/// **Call-waiting (current `AppDelegate+Voip` behavior):** This is **not** called from the PushKit
144+
/// path; CallKit handles multiple simultaneous calls. Kept for parity with Android busy detection,
145+
/// documentation of `prepareIncomingCall(_:storeEventsForJs:)`, and optional future or test use.
142146
public static func hasActiveCall() -> Bool {
143147
configureCallObserverIfNeeded()
144148
return callObserver.calls.contains { !$0.hasEnded }
@@ -533,6 +537,10 @@ public final class VoipService: NSObject {
533537

534538
/// Rejects an incoming call because the user is already on another call.
535539
/// Must be called **after** `reportNewIncomingCall` (PushKit requirement).
540+
///
541+
/// **Call-waiting:** `AppDelegate+Voip` does **not** invoke this; second rings are shown in CallKit
542+
/// instead of auto-rejecting. Same rationale as `hasActiveCall()` — API remains for Android-aligned
543+
/// flows, `storeEventsForJs: false` cleanup, and future wiring.
536544
public static func rejectBusyCall(_ payload: VoipPayload) {
537545
cancelIncomingCallTimeout(for: payload.callId)
538546
clearTrackedIncomingCall(for: payload.callUUID)

0 commit comments

Comments
 (0)