Skip to content

Commit 4850cdb

Browse files
[STREAM-878] - Check length of conversations object to pass in proper boolean into SVH
1 parent 2d86ade commit 4850cdb

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/headsets/headset-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface ISdkHeadsetService {
3030
retryConnection (micLabel: string): Promise<void>;
3131
setRinging (callInfo: { conversationId: string, contactName?: string }, hasOtherActiveCalls: boolean): Promise<void>;
3232
outgoingCall (callInfo: { conversationId: string, contactName?: string }): Promise<void>;
33-
endCurrentCall (conversationId: string): Promise<void>;
33+
endCurrentCall (conversationId: string, hasOtherActiveCalls: boolean): Promise<void>;
3434
endAllCalls (): Promise<void>;
3535
answerIncomingCall (conversationId: string, autoAnswer: boolean): Promise<void>;
3636
rejectIncomingCall (conversationId: string, expectExistingConversation?: boolean): Promise<void>;

src/headsets/headset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ export class HeadsetProxyService implements ISdkHeadsetService {
304304
return this.currentHeadsetService.outgoingCall(callInfo);
305305
}
306306

307-
endCurrentCall (conversationId: string): Promise<void> {
308-
return this.currentHeadsetService.endCurrentCall(conversationId);
307+
endCurrentCall (conversationId: string, hasOtherActiveCalls: boolean): Promise<void> {
308+
return this.currentHeadsetService.endCurrentCall(conversationId, hasOtherActiveCalls);
309309
}
310310

311311
endAllCalls (): Promise<void> {

src/headsets/sdk-headset-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export abstract class SdkHeadsetBase implements ISdkHeadsetService {
7272
* @param conversationId a string representing the conversation that needs to be ended
7373
* @returns Promise<void>
7474
*/
75-
async endCurrentCall (_conversationId: string): Promise<void> { /* no-op */ }
75+
async endCurrentCall (_conversationId: string, _hasOtherActiveCalls: boolean): Promise<void> { /* no-op */ }
7676

7777
/**
7878
* Calls the headset library's endAllCalls() function to signal the device

src/headsets/sdk-headset-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ export class SdkHeadsetService extends SdkHeadsetBase {
108108
* @param conversationId a string representing the conversation that needs to be ended
109109
* @returns Promise<void>
110110
*/
111-
async endCurrentCall (conversationId: string): Promise<void> {
111+
async endCurrentCall (conversationId: string, hasOtherActiveCalls: boolean): Promise<void> {
112112
if (conversationId) {
113-
return this.headsetLibrary.endCall(conversationId);
113+
return this.headsetLibrary.endCall(conversationId, hasOtherActiveCalls);
114114
}
115115
}
116116

src/sessions/softphone-session-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class SoftphoneSessionHandler extends BaseSessionHandler {
342342
if (this.isPendingState(previousCallState) && !isOutbound) {
343343
this.sdk.headset.rejectIncomingCall(conversationId);
344344
} else {
345-
this.sdk.headset.endCurrentCall(conversationId);
345+
this.sdk.headset.endCurrentCall(conversationId, Object.keys(this.conversations).length > 1);
346346
}
347347

348348
HeadsetChangesQueue.clearQueue();

test/unit/headset/headset.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ describe('SdkHeadsetService', () => {
145145
describe('endCurrentCall', () => {
146146
it('should call the proper function in the headset library', () => {
147147
const endCurrentCallSpy = jest.spyOn(headsetLibrary, 'endCall');
148-
sdkHeadset.endCurrentCall('');
148+
sdkHeadset.endCurrentCall('', false);
149149
expect(endCurrentCallSpy).not.toHaveBeenCalled();
150150

151-
sdkHeadset.endCurrentCall('123');
152-
expect(endCurrentCallSpy).toHaveBeenCalledWith('123');
151+
sdkHeadset.endCurrentCall('123', false);
152+
expect(endCurrentCallSpy).toHaveBeenCalledWith('123', false);
153153

154154
const endAllCallsSpy = jest.spyOn(headsetLibrary, 'endAllCalls');
155155
sdkHeadset.endAllCalls();
@@ -235,7 +235,7 @@ describe('SdkHeadsetServiceStub', () => {
235235

236236
describe('endCurrentCall()', () => {
237237
it('should return an empty promise', async () => {
238-
expect(await headsetStub.endCurrentCall('')).toBe(undefined);
238+
expect(await headsetStub.endCurrentCall('', false)).toBe(undefined);
239239
});
240240
});
241241

@@ -867,8 +867,8 @@ describe('HeadsetProxyService', () => {
867867
describe('endCurrentCall', () => {
868868
it('should proxy to headsetService', () => {
869869
const spy = currentHeadsetService.endCurrentCall = jest.fn();
870-
proxyService.endCurrentCall('123');
871-
expect(spy).toHaveBeenCalledWith('123');
870+
proxyService.endCurrentCall('123', false);
871+
expect(spy).toHaveBeenCalledWith('123', false);
872872
});
873873
});
874874

0 commit comments

Comments
 (0)