Calls: Fix errors when bundle is not loaded (#2518)

This commit is contained in:
Alexander Zinchuk 2023-02-08 00:47:36 +01:00
parent dcee60e77e
commit 0be5085d69
4 changed files with 13 additions and 11 deletions

View File

@ -253,7 +253,7 @@ addActionHandler('connectToActivePhoneCall', async (global, actions): Promise<vo
const result = await callApi('requestCall', { user, gAHash, isVideo: phoneCall.isVideo });
if (!result) {
actions.hangUp({ tabId: getCurrentTabId() });
if ('hangUp' in actions) actions.hangUp({ tabId: getCurrentTabId() });
return;
}
global = getGlobal();

View File

@ -36,7 +36,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
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;
}

View File

@ -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,

View File

@ -271,10 +271,12 @@ addActionHandler('joinGroupCall', async (global, actions, payload): Promise<void
}
if (activeGroupCallId) {
actions.leaveGroupCall({
rejoin: payload,
tabId,
});
if ('leaveGroupCall' in actions) {
actions.leaveGroupCall({
rejoin: payload,
tabId,
});
}
return;
}