From ed222fee9a8fc0d3bc3fba2ceaa7c11a7d9a2804 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:35:40 -0500 Subject: [PATCH] Poll for devices when joining a group call --- ts/services/calling.ts | 6 ++++-- ts/state/ducks/calling.ts | 6 +++--- ts/test-electron/state/ducks/calling_test.ts | 22 +++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 31b21c4737..4fccf05eaf 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -672,12 +672,12 @@ export class CallingClass { return outerGroupCall; } - public joinGroupCall( + public async joinGroupCall( conversationId: string, hasLocalAudio: boolean, hasLocalVideo: boolean, shouldRing: boolean - ): void { + ): Promise { const conversation = window.ConversationController.get( conversationId )?.format(); @@ -697,6 +697,8 @@ export class CallingClass { return; } + await this.startDeviceReselectionTimer(); + const groupCall = this.connectGroupCall(conversationId, { groupId: conversation.groupId, publicParams: conversation.publicParams, diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index 60fcbca5ed..4df2a8f938 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -538,7 +538,7 @@ function acceptCall( await calling.acceptDirectCall(conversationId, asVideoCall); break; case CallMode.Group: - calling.joinGroupCall(conversationId, true, asVideoCall, false); + await calling.joinGroupCall(conversationId, true, asVideoCall, false); break; default: throw missingCaseError(call); @@ -1104,7 +1104,7 @@ function showCallLobby(payload: ShowCallLobbyType): CallLobbyActionType { function startCall( payload: StartCallType ): ThunkAction { - return (dispatch, getState) => { + return async (dispatch, getState) => { switch (payload.callMode) { case CallMode.Direct: calling.startOutgoingDirectCall( @@ -1134,7 +1134,7 @@ function startCall( outgoingRing = false; } - calling.joinGroupCall( + await calling.joinGroupCall( payload.conversationId, payload.hasLocalAudio, payload.hasLocalVideo, diff --git a/ts/test-electron/state/ducks/calling_test.ts b/ts/test-electron/state/ducks/calling_test.ts index 7dc764af3a..13e2b64d70 100644 --- a/ts/test-electron/state/ducks/calling_test.ts +++ b/ts/test-electron/state/ducks/calling_test.ts @@ -336,10 +336,9 @@ describe('calling duck', () => { this.callingServiceAccept = this.sandbox .stub(callingService, 'acceptDirectCall') .resolves(); - this.callingServiceJoin = this.sandbox.stub( - callingService, - 'joinGroupCall' - ); + this.callingServiceJoin = this.sandbox + .stub(callingService, 'joinGroupCall') + .resolves(); }); describe('accepting a direct call', () => { @@ -1858,15 +1857,14 @@ describe('calling duck', () => { callingService, 'startOutgoingDirectCall' ); - this.callingJoinGroupCall = this.sandbox.stub( - callingService, - 'joinGroupCall' - ); + this.callingJoinGroupCall = this.sandbox + .stub(callingService, 'joinGroupCall') + .resolves(); }); - it('asks the calling service to start an outgoing direct call', function test() { + it('asks the calling service to start an outgoing direct call', async function test() { const dispatch = sinon.spy(); - startCall({ + await startCall({ callMode: CallMode.Direct, conversationId: '123', hasLocalAudio: true, @@ -1884,9 +1882,9 @@ describe('calling duck', () => { sinon.assert.notCalled(this.callingJoinGroupCall); }); - it('asks the calling service to join a group call', function test() { + it('asks the calling service to join a group call', async function test() { const dispatch = sinon.spy(); - startCall({ + await startCall({ callMode: CallMode.Group, conversationId: '123', hasLocalAudio: true,