From 0be5085d69de8d5533935706bc6711067d607bc8 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 8 Feb 2023 00:47:36 +0100 Subject: [PATCH] Calls: Fix errors when bundle is not loaded (#2518) --- src/global/actions/api/calls.async.ts | 2 +- src/global/actions/apiUpdaters/calls.async.ts | 8 ++++---- src/global/actions/apiUpdaters/calls.ts | 4 ++-- src/global/actions/ui/calls.ts | 10 ++++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/global/actions/api/calls.async.ts b/src/global/actions/api/calls.async.ts index cb00b5518..ac9604a94 100644 --- a/src/global/actions/api/calls.async.ts +++ b/src/global/actions/api/calls.async.ts @@ -253,7 +253,7 @@ addActionHandler('connectToActivePhoneCall', async (global, actions): Promise { if (!activeGroupCallId) break; if (update.connectionState === 'disconnected') { - actions.leaveGroupCall({ isFromLibrary: true, tabId: getCurrentTabId() }); + if ('leaveGroupCall' in actions) actions.leaveGroupCall({ isFromLibrary: true, tabId: getCurrentTabId() }); break; } @@ -55,7 +55,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { case 'updateGroupCallConnection': { if (update.data.stream) { actions.showNotification({ message: 'Big live streams are not yet supported', tabId: getCurrentTabId() }); - actions.leaveGroupCall({ tabId: getCurrentTabId() }); + if ('leaveGroupCall' in actions) actions.leaveGroupCall({ tabId: getCurrentTabId() }); break; } void handleUpdateGroupCallConnection(update.data, update.presentation); @@ -107,7 +107,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { if (state === 'active' || state === 'accepted') { if (!verifyPhoneCallProtocol(call.protocol)) { const user = selectPhoneCallUser(global); - actions.hangUp({ tabId: getCurrentTabId() }); + if ('hangUp' in actions) actions.hangUp({ tabId: getCurrentTabId() }); actions.showNotification({ message: langProvider.translate('VoipPeerIncompatible', user?.firstName), tabId: getCurrentTabId(), @@ -181,7 +181,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { if (!global.phoneCall) return global; if (connectionState === 'closed' || connectionState === 'disconnected' || connectionState === 'failed') { - actions.hangUp({ tabId: getCurrentTabId() }); + if ('hangUp' in actions) actions.hangUp({ tabId: getCurrentTabId() }); return undefined; } diff --git a/src/global/actions/apiUpdaters/calls.ts b/src/global/actions/apiUpdaters/calls.ts index 36ebf8780..55be51936 100644 --- a/src/global/actions/apiUpdaters/calls.ts +++ b/src/global/actions/apiUpdaters/calls.ts @@ -17,7 +17,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { case 'updateGroupCall': { if (update.call.connectionState === 'discarded') { if (global.groupCalls.activeGroupCallId) { - actions.leaveGroupCall({ shouldRemove: true, tabId: getCurrentTabId() }); + if ('leaveGroupCall' in actions) actions.leaveGroupCall({ shouldRemove: true, tabId: getCurrentTabId() }); return undefined; } else { return removeGroupCall(global, update.call.id); @@ -93,7 +93,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { if (phoneCall) { if (call.state === 'discarded') { actions.playGroupCallSound({ sound: 'end' }); - actions.hangUp({ tabId: getCurrentTabId() }); + if ('hangUp' in actions) actions.hangUp({ tabId: getCurrentTabId() }); return { ...global, diff --git a/src/global/actions/ui/calls.ts b/src/global/actions/ui/calls.ts index 6292645f8..51a034303 100644 --- a/src/global/actions/ui/calls.ts +++ b/src/global/actions/ui/calls.ts @@ -271,10 +271,12 @@ addActionHandler('joinGroupCall', async (global, actions, payload): Promise