diff --git a/src/components/calls/group/GroupCallTopPane.tsx b/src/components/calls/group/GroupCallTopPane.tsx index 59785e0ed..9647b87bf 100644 --- a/src/components/calls/group/GroupCallTopPane.tsx +++ b/src/components/calls/group/GroupCallTopPane.tsx @@ -1,6 +1,6 @@ import type { FC } from '../../../lib/teact/teact'; import React, { - memo, useCallback, useEffect, useMemo, + memo, useCallback, useMemo, } from '../../../lib/teact/teact'; import { getActions, getGlobal, withGlobal } from '../../../global'; @@ -41,7 +41,6 @@ const GroupCallTopPane: FC = ({ }) => { const { requestMasterAndJoinGroupCall, - subscribeToGroupCallUpdates, } = getActions(); const lang = useOldLang(); @@ -69,23 +68,6 @@ const GroupCallTopPane: FC = ({ .filter(Boolean); }, [participants]); - useEffect(() => { - if (!groupCall?.id) return undefined; - if (!isActive && groupCall.isLoaded) return undefined; - - subscribeToGroupCallUpdates({ - id: groupCall.id, - subscribed: true, - }); - - return () => { - subscribeToGroupCallUpdates({ - id: groupCall.id, - subscribed: false, - }); - }; - }, [groupCall?.id, groupCall?.isLoaded, isActive, subscribeToGroupCallUpdates]); - const renderingParticipantCount = useCurrentOrPrev(groupCall?.participantsCount, true); const renderingFetchedParticipants = useCurrentOrPrev(fetchedParticipants, true); diff --git a/src/global/actions/apiUpdaters/calls.ts b/src/global/actions/apiUpdaters/calls.ts index aab7cf637..09c2ba64b 100644 --- a/src/global/actions/apiUpdaters/calls.ts +++ b/src/global/actions/apiUpdaters/calls.ts @@ -107,9 +107,11 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => { if (!isOutgoing && call.state === 'requested') { onTickEnd(() => { global = getGlobal(); + const user = selectPhoneCallUser(global); + if (!user) return; notifyAboutCall({ call, - user: selectPhoneCallUser(global)!, + user, }); }); diff --git a/src/global/actions/ui/calls.ts b/src/global/actions/ui/calls.ts index 3eeced719..c57245c3e 100644 --- a/src/global/actions/ui/calls.ts +++ b/src/global/actions/ui/calls.ts @@ -131,26 +131,6 @@ addActionHandler('toggleGroupCallPanel', (global, actions, payload): ActionRetur }, tabId); }); -addActionHandler('subscribeToGroupCallUpdates', async (global, actions, payload): Promise => { - if (selectIsCurrentUserFrozen(global)) return; - - const { subscribed, id } = payload; - const groupCall = selectGroupCall(global, id); - - if (!groupCall) return; - - if (subscribed) { - await fetchGroupCall(global, groupCall); - global = getGlobal(); - await requestGroupCallParticipants(groupCall); - } - - await callApi('toggleGroupCallStartSubscription', { - subscribed, - call: groupCall, - }); -}); - addActionHandler('createGroupCall', async (global, actions, payload): Promise => { const { chatId, tabId = getCurrentTabId() } = payload; @@ -341,7 +321,7 @@ addActionHandler('joinGroupCall', async (global, actions, payload): Promise { const { sound } = payload; - if (!sounds[sound]) { + if (!sounds?.[sound]) { return; } diff --git a/src/global/types/actions.ts b/src/global/types/actions.ts index c58cce2aa..c392cd603 100644 --- a/src/global/types/actions.ts +++ b/src/global/types/actions.ts @@ -2265,10 +2265,6 @@ export interface ActionPayloads { username: string; inviteHash: string; } & WithTabId; - subscribeToGroupCallUpdates: { - subscribed: boolean; - id: string; - }; createGroupCallInviteLink: WithTabId | undefined; loadMoreGroupCallParticipants: undefined;