fix(calls): fix some bugs encountered during refactor

This commit is contained in:
Taso committed 2021-07-28 14:26:01 -04:00
1 parent 10c5e97088
commit af6e291368
9 files changed
+15 -15

No files matched your search

@@ -7,11 +7,8 @@ import { useApp } from '../../../os/apps/hooks/useApps';
import { Switch, Route } from 'react-router-dom'; import { Switch, Route } from 'react-router-dom';
import DialPage from './views/DialPage'; import DialPage from './views/DialPage';
import DialerNavBar from './DialerNavBar'; import DialerNavBar from './DialerNavBar';
import { useDialHistory } from '../hooks/useDialHistory';
import InjectDebugData from '../../../os/debug/InjectDebugData';
import { ContactList } from '../../contacts/components/List/ContactList'; import { ContactList } from '../../contacts/components/List/ContactList';
import { DialerThemeProvider } from '../providers/DialerThemeProvider'; import { DialerThemeProvider } from '../providers/DialerThemeProvider';
import { CallEvents } from '../../../../../typings/call';
import { Box, CircularProgress } from '@material-ui/core'; import { Box, CircularProgress } from '@material-ui/core';
const LoadingSpinner: React.FC = () => ( const LoadingSpinner: React.FC = () => (
@@ -48,7 +48,7 @@ export const CallControls = ({ isSmall }: { isSmall?: boolean }) => {
// We display only the hang up if the call is accepted // We display only the hang up if the call is accepted
// or we are the one calling // or we are the one calling
if (call.accepted || call.isTransmitter) if (call.is_accepted || call.isTransmitter)
return ( return (
<Box display="flex" justifyContent="center" px={2} my={2}> <Box display="flex" justifyContent="center" px={2} my={2}>
<StatusIconButton <StatusIconButton
+2 -2
View File
@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { AppWrapper } from '../../../ui/components/AppWrapper'; import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent'; import { AppContent } from '../../../ui/components/AppContent';
import { useCall } from '../hooks/useCall'; import { useCall } from '../hooks/useCall';
import { CallTimer } from './CallTimer'; import { CallTimer } from './CallTimer';
@@ -37,7 +37,7 @@ export const CallModal = () => {
<Box className={classes.root} padding={5}> <Box className={classes.root} padding={5}>
<Box> <Box>
<CallContactContainer /> <CallContactContainer />
{call.accepted ? <CallTimer /> : call.isTransmitter && <RingingText />} {call.is_accepted ? <CallTimer /> : call.isTransmitter && <RingingText />}
</Box> </Box>
<CallControls /> <CallControls />
</Box> </Box>
@@ -33,7 +33,7 @@ export const useCallNotifications = () => {
removeId(NOTIFICATION_ID); removeId(NOTIFICATION_ID);
return; return;
} }
if (call.accepted) { if (call.is_accepted) {
removeId(NOTIFICATION_ID); removeId(NOTIFICATION_ID);
addNotification({ addNotification({
...callNotificationBase, ...callNotificationBase,
@@ -47,7 +47,7 @@ export const useCallNotifications = () => {
title: t('APPS_DIALER_CURRENT_CALL_TITLE'), title: t('APPS_DIALER_CURRENT_CALL_TITLE'),
}); });
} }
if (!call.isTransmitter && !call.accepted) { if (!call.isTransmitter && !call.is_accepted) {
play(); play();
removeId(NOTIFICATION_ID); removeId(NOTIFICATION_ID);
addNotificationAlert( addNotificationAlert(
@@ -1,6 +1,7 @@
import { import {
CallEvents, CallEvents,
CallWasAcceptedEvent, CallWasAcceptedEvent,
EndCallDTO,
InitializeCallDTO, InitializeCallDTO,
StartCallEventData, StartCallEventData,
TransmitterNumDTO, TransmitterNumDTO,
@@ -57,7 +58,7 @@ onNetTyped<CallWasAcceptedEvent>(
// Rejected call // Rejected call
RegisterNuiCB<TransmitterNumDTO>(CallEvents.REJECTED, (data, cb: NuiCallbackFunc) => { RegisterNuiCB<TransmitterNumDTO>(CallEvents.REJECTED, (data, cb: NuiCallbackFunc) => {
emitNet(CallEvents.REJECTED, data.transmitterNumber); emitNetTyped<TransmitterNumDTO>(CallEvents.REJECTED, data);
cb({}); cb({});
}); });
@@ -66,7 +67,7 @@ onNet(CallEvents.WAS_REJECTED, async () => {
animationService.endPhoneCall(); animationService.endPhoneCall();
}); });
RegisterNuiCB<TransmitterNumDTO>(CallEvents.END_CALL, async (data, cb) => { RegisterNuiCB<EndCallDTO>(CallEvents.END_CALL, async (data, cb) => {
try { try {
const serverRes: ServerPromiseResp<void> = await ClUtils.emitNetPromise( const serverRes: ServerPromiseResp<void> = await ClUtils.emitNetPromise(
CallEvents.END_CALL, CallEvents.END_CALL,
@@ -1,5 +1,6 @@
import { IAlertProps } from '../../../typings/alerts'; import { IAlertProps } from '../../../typings/alerts';
import { CallEvents, CallHistoryItem, CallRejectReasons } from '../../../typings/call'; import { CallEvents, CallHistoryItem, CallRejectReasons } from '../../../typings/call';
import { animationService } from '../animations/animation.controller';
const exp = (global as any).exports; const exp = (global as any).exports;
@@ -45,6 +46,7 @@ export class CallService {
return emitNet(CallEvents.REJECTED, transmitter, CallRejectReasons.BUSY_LINE); return emitNet(CallEvents.REJECTED, transmitter, CallRejectReasons.BUSY_LINE);
this.openCallModal(true); this.openCallModal(true);
animationService.startPhoneCall();
SendNUIMessage({ SendNUIMessage({
app: 'CALL', app: 'CALL',
+2 -2
View File
@@ -18,7 +18,7 @@ onNetPromise<InitializeCallDTO, StartCallEventData>(CallEvents.INITIALIZE_CALL,
}); });
}); });
onNetTyped(CallEvents.ACCEPT_CALL, (transmitterNumber: string) => { onNetTyped<TransmitterNumDTO>(CallEvents.ACCEPT_CALL, ({ transmitterNumber }) => {
const src = getSource(); const src = getSource();
CallService.handleAcceptCall(src, transmitterNumber).catch((e) => CallService.handleAcceptCall(src, transmitterNumber).catch((e) =>
callLogger.error( callLogger.error(
@@ -41,7 +41,7 @@ onNetTyped<TransmitterNumDTO>(CallEvents.REJECTED, (data) => {
onNetPromise<EndCallDTO, void>(CallEvents.END_CALL, (reqObj, resp) => { onNetPromise<EndCallDTO, void>(CallEvents.END_CALL, (reqObj, resp) => {
CallService.handleEndCall(reqObj, resp).catch((e) => { CallService.handleEndCall(reqObj, resp).catch((e) => {
callLogger.error( 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' }); resp({ status: 'error', errorMsg: 'SERVER_ERROR' });
}); });
+1 -1
View File
@@ -196,7 +196,7 @@ class CallsService {
} }
async handleEndCall(reqObj: PromiseRequest<EndCallDTO>, resp: PromiseEventResp<void>) { async handleEndCall(reqObj: PromiseRequest<EndCallDTO>, resp: PromiseEventResp<void>) {
const transmitterNumber = reqObj.data.transmitter; const transmitterNumber = reqObj.data.transmitterNumber;
const endCallTimeUnix = Math.floor(new Date().getTime() / 1000); const endCallTimeUnix = Math.floor(new Date().getTime() / 1000);
const currentCall = this.callMap.get(transmitterNumber); const currentCall = this.callMap.get(transmitterNumber);
+2 -2
View File
@@ -1,6 +1,6 @@
export interface ActiveCall { export interface ActiveCall {
active: boolean; active: boolean;
accepted: boolean; is_accepted: boolean;
isTransmitter: boolean; isTransmitter: boolean;
transmitter: string; transmitter: string;
receiver: string; receiver: string;
@@ -22,7 +22,7 @@ export interface StartCallEventData {
} }
export interface EndCallDTO { export interface EndCallDTO {
transmitter: string; transmitterNumber: string;
isTransmitter: boolean; isTransmitter: boolean;
} }