From 2de45a341b64400708ebfa73cb5a2bf6bf83aa1d Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 18 Feb 2022 08:27:15 -0800 Subject: [PATCH] hangup: Hang up all calls, warn if we can't find intended call --- ts/services/calling.ts | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 14fa3dd99..4df018c73 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -1059,24 +1059,33 @@ export class CallingClass { hangup(conversationId: string): void { log.info('CallingClass.hangup()'); - const call = getOwn(this.callsByConversation, conversationId); - if (!call) { - log.warn('Trying to hang up a non-existent call'); - return; + const specificCall = getOwn(this.callsByConversation, conversationId); + if (!specificCall) { + log.error( + `hangup: Trying to hang up a non-existent call for conversation ${conversationId}` + ); } ipcRenderer.send('close-screen-share-controller'); - if (call instanceof Call) { - RingRTC.hangup(call.callId); - } else if (call instanceof GroupCall) { - // This ensures that we turn off our devices. - call.setOutgoingAudioMuted(true); - call.setOutgoingVideoMuted(true); - call.disconnect(); - } else { - throw missingCaseError(call); - } + const entries = Object.entries(this.callsByConversation); + log.info(`hangup: ${entries.length} call(s) to hang up...`); + + entries.forEach(([callConversationId, call]) => { + log.info(`hangup: Hanging up conversation ${callConversationId}`); + if (call instanceof Call) { + RingRTC.hangup(call.callId); + } else if (call instanceof GroupCall) { + // This ensures that we turn off our devices. + call.setOutgoingAudioMuted(true); + call.setOutgoingVideoMuted(true); + call.disconnect(); + } else { + throw missingCaseError(call); + } + }); + + log.info('hangup: Done.'); } setOutgoingAudio(conversationId: string, enabled: boolean): void {