Skip to content

Commit

Permalink
Regression: VoIp wrap up modal not opening after call disconnect (#25651
Browse files Browse the repository at this point in the history
)
  • Loading branch information
aleksandernsilva authored May 26, 2022
1 parent 3cd0cab commit 052858d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/client/components/Omnichannel/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formsSubscription } from '../../views/omnichannel/additionalForms';
import { FormSkeleton } from './Skeleton';

const Tags = ({
tags,
tags = [],
handler,
error,
tagRequired,
Expand Down
18 changes: 11 additions & 7 deletions apps/meteor/client/providers/CallProvider/CallProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { IVoipRoom, IUser, VoipEventDataSignature } from '@rocket.chat/core-typings';
import {
IVoipRoom,
IUser,
VoipEventDataSignature,
VoipClientEvents,
ICallerInfo,
isVoipEventAgentCalled,
isVoipEventAgentConnected,
Expand All @@ -9,7 +12,7 @@ import {
isVoipEventCallAbandoned,
} from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useSetModal, useRoute, useUser, useSetting, useEndpoint, useStream } from '@rocket.chat/ui-contexts';
import { useRoute, useUser, useSetting, useEndpoint, useStream } from '@rocket.chat/ui-contexts';
import { Random } from 'meteor/random';
import React, { useMemo, FC, useRef, useCallback, useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
Expand All @@ -19,6 +22,7 @@ import { CustomSounds } from '../../../app/custom-sounds/client';
import { getUserPreference } from '../../../app/utils/client';
import { WrapUpCallModal } from '../../components/voip/modal/WrapUpCallModal';
import { CallContext, CallContextValue } from '../../contexts/CallContext';
import { imperativeModal } from '../../lib/imperativeModal';
import { roomCoordinator } from '../../lib/rooms/roomCoordinator';
import { QueueAggregator } from '../../lib/voip/QueueAggregator';
import { useVoipClient } from './hooks/useVoipClient';
Expand All @@ -40,6 +44,7 @@ type NetworkState = 'online' | 'offline';
export const CallProvider: FC = ({ children }) => {
const voipEnabled = useSetting('VoIP_Enabled');
const subscribeToNotifyUser = useStream('notify-user');
const dispatchEvent = useEndpoint('POST', 'voip/events');

const result = useVoipClient();
const user = useUser();
Expand All @@ -50,11 +55,9 @@ export const CallProvider: FC = ({ children }) => {
const [queueCounter, setQueueCounter] = useState(0);
const [queueName, setQueueName] = useState('');

const setModal = useSetModal();

const openWrapUpModal = useCallback((): void => {
setModal(<WrapUpCallModal />);
}, [setModal]);
imperativeModal.open({ component: WrapUpCallModal });

This comment has been minimized.

Copy link
@ggazzo

ggazzo May 26, 2022

Member

why did you change from setModal?

}, []);

const [queueAggregator, setQueueAggregator] = useState<QueueAggregator>();

Expand Down Expand Up @@ -129,10 +132,11 @@ export const CallProvider: FC = ({ children }) => {
const handleCallHangup = (_event: { roomId: string }): void => {
setQueueName(queueAggregator.getCurrentQueueName());
openWrapUpModal();
dispatchEvent({ event: VoipClientEvents['VOIP-CALL-ENDED'], rid: _event.roomId });
};

return subscribeToNotifyUser(`${user._id}/call.hangup`, handleCallHangup);
}, [openWrapUpModal, queueAggregator, subscribeToNotifyUser, user, voipEnabled]);
}, [openWrapUpModal, queueAggregator, subscribeToNotifyUser, user, voipEnabled, dispatchEvent]);

useEffect(() => {
if (!result.voipClient) {
Expand Down
2 changes: 0 additions & 2 deletions apps/meteor/client/sidebar/footer/voip/VoipFooter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const IncomingCall = (): ReactElement => {
createRoom={() => ''}
openRoom={() => ''}
callsInQueue='2 Calls In Queue'
openWrapUpCallModal={() => null}
dispatchEvent={() => null}
openedRoomInfo={{ v: { token: '' }, rid: '' }}
anonymousText={'Anonymous'}
Expand Down Expand Up @@ -88,7 +87,6 @@ export const InCall = (): ReactElement => {
createRoom={() => ''}
openRoom={() => ''}
callsInQueue='2 Calls In Queue'
openWrapUpCallModal={() => null}
dispatchEvent={() => null}
openedRoomInfo={{ v: { token: '' }, rid: '' }}
anonymousText={'Anonymous'}
Expand Down
5 changes: 0 additions & 5 deletions apps/meteor/client/sidebar/footer/voip/VoipFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type VoipFooterPropsType = {
};
callsInQueue: string;

openWrapUpCallModal: () => void;
createRoom: (caller: ICallerInfo) => IVoipRoom['_id'];
openRoom: (rid: IVoipRoom['_id']) => void;
dispatchEvent: (params: { event: VoipClientEvents; rid: string; comment?: string }) => void;
Expand All @@ -46,7 +45,6 @@ export const VoipFooter = ({
createRoom,
openRoom,
callsInQueue,
openWrapUpCallModal,
dispatchEvent,
openedRoomInfo,
anonymousText,
Expand Down Expand Up @@ -137,9 +135,6 @@ export const VoipFooter = ({
e.stopPropagation();
toggleMic(false);
togglePause(false);
openWrapUpCallModal();
dispatchEvent({ event: VoipClientEvents['VOIP-CALL-ENDED'], rid: openedRoomInfo.rid });

return callActions.end();
}}
>
Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/client/sidebar/footer/voip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
useOpenedRoomInfo,
useQueueCounter,
useQueueName,
useWrapUpModal,
} from '../../../contexts/CallContext';
import { VoipFooter as VoipFooterComponent } from './VoipFooter';

Expand All @@ -23,7 +22,6 @@ export const VoipFooter = (): ReactElement | null => {
const openRoom = useCallOpenRoom();
const queueCounter = useQueueCounter();
const queueName = useQueueName();
const openWrapUpCallModal = useWrapUpModal();
const openedRoomInfo = useOpenedRoomInfo();

const [muted, setMuted] = useState(false);
Expand Down Expand Up @@ -97,7 +95,6 @@ export const VoipFooter = (): ReactElement | null => {
createRoom={createRoom}
openRoom={openRoom}
callsInQueue={getCallsInQueueText}
openWrapUpCallModal={openWrapUpCallModal}
dispatchEvent={dispatchEvent}
openedRoomInfo={openedRoomInfo}
anonymousText={t('Anonymous')}
Expand Down

0 comments on commit 052858d

Please sign in to comment.