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 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 = () => (
@@ -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 (
<Box display="flex" justifyContent="center" px={2} my={2}>
<StatusIconButton
+2 -2
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { AppWrapper } from '../../../ui/components/AppWrapper';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { useCall } from '../hooks/useCall';
import { CallTimer } from './CallTimer';
@@ -37,7 +37,7 @@ export const CallModal = () => {
<Box className={classes.root} padding={5}>
<Box>
<CallContactContainer />
{call.accepted ? <CallTimer /> : call.isTransmitter && <RingingText />}
{call.is_accepted ? <CallTimer /> : call.isTransmitter && <RingingText />}
</Box>
<CallControls />
</Box>
@@ -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(
@@ -1,6 +1,7 @@
import {
CallEvents,
CallWasAcceptedEvent,
EndCallDTO,
InitializeCallDTO,
StartCallEventData,
TransmitterNumDTO,
@@ -57,7 +58,7 @@ onNetTyped<CallWasAcceptedEvent>(
// Rejected call
RegisterNuiCB<TransmitterNumDTO>(CallEvents.REJECTED, (data, cb: NuiCallbackFunc) => {
emitNet(CallEvents.REJECTED, data.transmitterNumber);
emitNetTyped<TransmitterNumDTO>(CallEvents.REJECTED, data);
cb({});
});
@@ -66,7 +67,7 @@ onNet(CallEvents.WAS_REJECTED, async () => {
animationService.endPhoneCall();
});
RegisterNuiCB<TransmitterNumDTO>(CallEvents.END_CALL, async (data, cb) => {
RegisterNuiCB<EndCallDTO>(CallEvents.END_CALL, async (data, cb) => {
try {
const serverRes: ServerPromiseResp<void> = await ClUtils.emitNetPromise(
CallEvents.END_CALL,
@@ -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',
+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();
CallService.handleAcceptCall(src, transmitterNumber).catch((e) =>
callLogger.error(
@@ -41,7 +41,7 @@ onNetTyped<TransmitterNumDTO>(CallEvents.REJECTED, (data) => {
onNetPromise<EndCallDTO, void>(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' });
});
+1 -1
View File
@@ -196,7 +196,7 @@ class CallsService {
}
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 currentCall = this.callMap.get(transmitterNumber);
+2 -2
View File
@@ -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;
}