Calls: Discard incoming calls as busy when already in a call (#6952)
This commit is contained in:
parent
198da4736e
commit
e6ba963240
@ -102,6 +102,14 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
if (!ARE_CALLS_SUPPORTED) return undefined;
|
if (!ARE_CALLS_SUPPORTED) return undefined;
|
||||||
const { phoneCall, currentUserId } = global;
|
const { phoneCall, currentUserId } = global;
|
||||||
|
|
||||||
|
// Another call (P2P or group) is already active - ignore here so we don't show the popup;
|
||||||
|
// the non-async handler discards the new call as busy.
|
||||||
|
const isInOtherPhoneCall = Boolean(phoneCall?.id) && update.call.id !== phoneCall?.id;
|
||||||
|
const isInGroupCall = Boolean(global.groupCalls.activeGroupCallId) && !phoneCall;
|
||||||
|
if (isInOtherPhoneCall || isInGroupCall) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const call: ApiPhoneCall = {
|
const call: ApiPhoneCall = {
|
||||||
...phoneCall,
|
...phoneCall,
|
||||||
...update.call,
|
...update.call,
|
||||||
@ -116,16 +124,6 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
|
|
||||||
if (phoneCall && phoneCall.id && call.id !== phoneCall.id) {
|
|
||||||
if (call.state !== 'discarded') {
|
|
||||||
callApi('discardCall', {
|
|
||||||
call,
|
|
||||||
isBusy: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
accessHash, state, connections, gB,
|
accessHash, state, connections, gB,
|
||||||
} = call;
|
} = call;
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
|||||||
import { omit } from '../../../util/iteratees';
|
import { omit } from '../../../util/iteratees';
|
||||||
import { notifyAboutCall } from '../../../util/notifications';
|
import { notifyAboutCall } from '../../../util/notifications';
|
||||||
import { onTickEnd } from '../../../util/schedulers';
|
import { onTickEnd } from '../../../util/schedulers';
|
||||||
|
import { callApi } from '../../../api/gramjs';
|
||||||
import { addActionHandler, getGlobal } from '../../index';
|
import { addActionHandler, getGlobal } from '../../index';
|
||||||
import { updateChat, updateChatFullInfo } from '../../reducers';
|
import { updateChat, updateChatFullInfo } from '../../reducers';
|
||||||
import { removeGroupCall, updateGroupCall, updateGroupCallParticipant } from '../../reducers/calls';
|
import { removeGroupCall, updateGroupCall, updateGroupCallParticipant } from '../../reducers/calls';
|
||||||
@ -88,6 +89,19 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
|
|
||||||
const { call } = update;
|
const { call } = update;
|
||||||
|
|
||||||
|
// Another call (P2P or group) is already active: auto-discard the new incoming call as busy.
|
||||||
|
const isInOtherPhoneCall = Boolean(phoneCall) && call.id !== phoneCall.id;
|
||||||
|
const isInGroupCall = Boolean(global.groupCalls.activeGroupCallId) && !phoneCall;
|
||||||
|
if (isInOtherPhoneCall || isInGroupCall) {
|
||||||
|
if (call.state !== 'discarded') {
|
||||||
|
callApi('discardCall', {
|
||||||
|
call,
|
||||||
|
isBusy: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (phoneCall) {
|
if (phoneCall) {
|
||||||
if (call.state === 'discarded') {
|
if (call.state === 'discarded') {
|
||||||
actions.playGroupCallSound({ sound: 'end' });
|
actions.playGroupCallSound({ sound: 'end' });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user