From af6e291368e28044ecf6e8b369b8994f3ba23fe6 Mon Sep 17 00:00:00 2001 From: Taso Date: Wed, 28 Jul 2021 14:19:37 -0400 Subject: [PATCH] fix(calls): fix some bugs encountered during refactor --- phone/src/apps/dialer/components/DialerApp.tsx | 3 --- phone/src/os/call/components/CallControls.tsx | 2 +- phone/src/os/call/components/CallModal.tsx | 4 ++-- phone/src/os/call/hooks/useCallNotifications.tsx | 4 ++-- resources/client/calls/cl_calls.controller.ts | 5 +++-- resources/client/calls/cl_calls.service.ts | 2 ++ resources/server/calls/calls.controller.ts | 4 ++-- resources/server/calls/calls.service.ts | 2 +- typings/call.ts | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/phone/src/apps/dialer/components/DialerApp.tsx b/phone/src/apps/dialer/components/DialerApp.tsx index a479dbe..f9d0966 100644 --- a/phone/src/apps/dialer/components/DialerApp.tsx +++ b/phone/src/apps/dialer/components/DialerApp.tsx @@ -7,11 +7,8 @@ import { useApp } from '../../../os/apps/hooks/useApps'; import { Switch, Route } from 'react-router-dom'; import DialPage from './views/DialPage'; import DialerNavBar from './DialerNavBar'; -import { useDialHistory } from '../hooks/useDialHistory'; -import InjectDebugData from '../../../os/debug/InjectDebugData'; import { ContactList } from '../../contacts/components/List/ContactList'; import { DialerThemeProvider } from '../providers/DialerThemeProvider'; -import { CallEvents } from '../../../../../typings/call'; import { Box, CircularProgress } from '@material-ui/core'; const LoadingSpinner: React.FC = () => ( diff --git a/phone/src/os/call/components/CallControls.tsx b/phone/src/os/call/components/CallControls.tsx index fe7ae23..fd9f766 100644 --- a/phone/src/os/call/components/CallControls.tsx +++ b/phone/src/os/call/components/CallControls.tsx @@ -48,7 +48,7 @@ export const CallControls = ({ isSmall }: { isSmall?: boolean }) => { // We display only the hang up if the call is accepted // or we are the one calling - if (call.accepted || call.isTransmitter) + if (call.is_accepted || call.isTransmitter) return ( { - {call.accepted ? : call.isTransmitter && } + {call.is_accepted ? : call.isTransmitter && } diff --git a/phone/src/os/call/hooks/useCallNotifications.tsx b/phone/src/os/call/hooks/useCallNotifications.tsx index 46b47a6..38b0961 100644 --- a/phone/src/os/call/hooks/useCallNotifications.tsx +++ b/phone/src/os/call/hooks/useCallNotifications.tsx @@ -33,7 +33,7 @@ export const useCallNotifications = () => { removeId(NOTIFICATION_ID); return; } - if (call.accepted) { + if (call.is_accepted) { removeId(NOTIFICATION_ID); addNotification({ ...callNotificationBase, @@ -47,7 +47,7 @@ export const useCallNotifications = () => { title: t('APPS_DIALER_CURRENT_CALL_TITLE'), }); } - if (!call.isTransmitter && !call.accepted) { + if (!call.isTransmitter && !call.is_accepted) { play(); removeId(NOTIFICATION_ID); addNotificationAlert( diff --git a/resources/client/calls/cl_calls.controller.ts b/resources/client/calls/cl_calls.controller.ts index 8a57dd8..3071ff9 100644 --- a/resources/client/calls/cl_calls.controller.ts +++ b/resources/client/calls/cl_calls.controller.ts @@ -1,6 +1,7 @@ import { CallEvents, CallWasAcceptedEvent, + EndCallDTO, InitializeCallDTO, StartCallEventData, TransmitterNumDTO, @@ -57,7 +58,7 @@ onNetTyped( // Rejected call RegisterNuiCB(CallEvents.REJECTED, (data, cb: NuiCallbackFunc) => { - emitNet(CallEvents.REJECTED, data.transmitterNumber); + emitNetTyped(CallEvents.REJECTED, data); cb({}); }); @@ -66,7 +67,7 @@ onNet(CallEvents.WAS_REJECTED, async () => { animationService.endPhoneCall(); }); -RegisterNuiCB(CallEvents.END_CALL, async (data, cb) => { +RegisterNuiCB(CallEvents.END_CALL, async (data, cb) => { try { const serverRes: ServerPromiseResp = await ClUtils.emitNetPromise( CallEvents.END_CALL, diff --git a/resources/client/calls/cl_calls.service.ts b/resources/client/calls/cl_calls.service.ts index 0b891db..b5b3c0f 100644 --- a/resources/client/calls/cl_calls.service.ts +++ b/resources/client/calls/cl_calls.service.ts @@ -1,5 +1,6 @@ import { IAlertProps } from '../../../typings/alerts'; import { CallEvents, CallHistoryItem, CallRejectReasons } from '../../../typings/call'; +import { animationService } from '../animations/animation.controller'; const exp = (global as any).exports; @@ -45,6 +46,7 @@ export class CallService { return emitNet(CallEvents.REJECTED, transmitter, CallRejectReasons.BUSY_LINE); this.openCallModal(true); + animationService.startPhoneCall(); SendNUIMessage({ app: 'CALL', diff --git a/resources/server/calls/calls.controller.ts b/resources/server/calls/calls.controller.ts index 2edc584..d92c226 100644 --- a/resources/server/calls/calls.controller.ts +++ b/resources/server/calls/calls.controller.ts @@ -18,7 +18,7 @@ onNetPromise(CallEvents.INITIALIZE_CALL, }); }); -onNetTyped(CallEvents.ACCEPT_CALL, (transmitterNumber: string) => { +onNetTyped(CallEvents.ACCEPT_CALL, ({ transmitterNumber }) => { const src = getSource(); CallService.handleAcceptCall(src, transmitterNumber).catch((e) => callLogger.error( @@ -41,7 +41,7 @@ onNetTyped(CallEvents.REJECTED, (data) => { onNetPromise(CallEvents.END_CALL, (reqObj, resp) => { CallService.handleEndCall(reqObj, resp).catch((e) => { callLogger.error( - `Error occured in end call event (${reqObj.data.transmitter}), Error: ${e.message}`, + `Error occured in end call event (${reqObj.data.transmitterNumber}), Error: ${e.message}`, ); resp({ status: 'error', errorMsg: 'SERVER_ERROR' }); }); diff --git a/resources/server/calls/calls.service.ts b/resources/server/calls/calls.service.ts index c823fbe..29ae06e 100644 --- a/resources/server/calls/calls.service.ts +++ b/resources/server/calls/calls.service.ts @@ -196,7 +196,7 @@ class CallsService { } async handleEndCall(reqObj: PromiseRequest, resp: PromiseEventResp) { - const transmitterNumber = reqObj.data.transmitter; + const transmitterNumber = reqObj.data.transmitterNumber; const endCallTimeUnix = Math.floor(new Date().getTime() / 1000); const currentCall = this.callMap.get(transmitterNumber); diff --git a/typings/call.ts b/typings/call.ts index f648a80..bd3f760 100644 --- a/typings/call.ts +++ b/typings/call.ts @@ -1,6 +1,6 @@ export interface ActiveCall { active: boolean; - accepted: boolean; + is_accepted: boolean; isTransmitter: boolean; transmitter: string; receiver: string; @@ -22,7 +22,7 @@ export interface StartCallEventData { } export interface EndCallDTO { - transmitter: string; + transmitterNumber: string; isTransmitter: boolean; }