Calls: Fix inconsistent global usage

This commit is contained in:
Alexander Zinchuk 2022-05-16 13:34:03 +02:00
parent 2e156d7ef4
commit 4dfbc58976

View File

@ -7,6 +7,7 @@ import { ARE_CALLS_SUPPORTED } from '../../../util/environment';
import { notifyAboutCall } from '../../../util/notifications'; import { notifyAboutCall } from '../../../util/notifications';
import { selectPhoneCallUser } from '../../selectors/calls'; import { selectPhoneCallUser } from '../../selectors/calls';
import { initializeSoundsForSafari } from '../ui/calls'; import { initializeSoundsForSafari } from '../ui/calls';
import { onTickEnd } from '../../../util/schedulers';
addActionHandler('apiUpdate', (global, actions, update) => { addActionHandler('apiUpdate', (global, actions, update) => {
switch (update['@type']) { switch (update['@type']) {
@ -20,11 +21,13 @@ addActionHandler('apiUpdate', (global, actions, update) => {
} }
} }
return updateGroupCall(global, return updateGroupCall(
global,
update.call.id, update.call.id,
omit(update.call, ['connectionState']), omit(update.call, ['connectionState']),
undefined, undefined,
update.call.participantsCount); update.call.participantsCount,
);
} }
case 'updateGroupCallChatId': { case 'updateGroupCallChatId': {
const chat = selectChat(global, update.chatId); const chat = selectChat(global, update.chatId);
@ -72,10 +75,13 @@ addActionHandler('apiUpdate', (global, actions, update) => {
const isOutgoing = call?.adminId === currentUserId; const isOutgoing = call?.adminId === currentUserId;
if (!isOutgoing && call.state === 'requested') { if (!isOutgoing && call.state === 'requested') {
notifyAboutCall({ onTickEnd(() => {
call, notifyAboutCall({
user: selectPhoneCallUser(global)!, call,
user: selectPhoneCallUser(global)!,
});
}); });
void initializeSoundsForSafari(); void initializeSoundsForSafari();
return { return {
...global, ...global,