fix(calls): Fix incorrect data type being sent over net

This commit is contained in:
Taso committed 2021-07-29 20:29:27 -04:00
1 parent 60b9e35ae8
commit 5263a83d1f
10 files changed
+99 -107

No files matched your search

+16 -51
View File
@@ -1,5 +1,5 @@
import { IAlertProps } from '../../../typings/alerts';
import { CallEvents, CallHistoryItem, CallRejectReasons } from '../../../typings/call';
import { ActiveCall, CallEvents, CallRejectReasons } from '../../../typings/call';
import { animationService } from '../animations/animation.controller';
const exp = (global as any).exports;
@@ -11,33 +11,27 @@ export class CallService {
this.currentCall = 0;
}
static sendCallAction<T>(method: CallEvents, data: T): void {
SendNUIMessage({
app: 'CALL',
method,
data,
});
}
isInCall() {
return this.currentCall !== 0;
}
openCallModal(show: boolean) {
SendNUIMessage({
app: 'CALL',
method: CallEvents.SET_CALL_MODAL,
data: show,
});
CallService.sendCallAction<boolean>(CallEvents.SET_CALL_MODAL, show);
}
handleRejectCall() {
// we don't want to reset our UI if we're in a call already.
if (this.isInCall()) return;
this.openCallModal(false);
SendNUIMessage({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
transmitter: null,
receiver: null,
isTransmitter: null,
accepted: false,
active: false,
},
});
CallService.sendCallAction(CallEvents.SET_CALLER, null);
}
handleStartCall(transmitter: string, receiver: string, isTransmitter: boolean) {
@@ -61,21 +55,10 @@ export class CallService {
});
}
handleCallAccepted(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) {
this.currentCall = channelId;
exp['pma-voice'].setCallChannel(channelId);
// phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
SendNUIMessage({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
active: true,
transmitter: currentCall.transmitter,
receiver: currentCall.receiver,
isTransmitter: isTransmitter,
accepted: true,
},
});
handleCallAccepted(callData: ActiveCall) {
this.currentCall = callData.channelId;
exp['pma-voice'].setCallChannel(callData.channelId);
CallService.sendCallAction<ActiveCall>(CallEvents.SET_CALLER, callData);
}
handleEndCall() {
@@ -83,17 +66,7 @@ export class CallService {
exp['pma-voice'].setCallChannel(0);
this.openCallModal(false);
SendNUIMessage({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
transmitter: null,
receiver: null,
isTransmitter: null,
accepted: false,
active: false,
},
});
CallService.sendCallAction<null>(CallEvents.SET_CALLER, null);
}
handleSendAlert(alert: IAlertProps) {
@@ -103,12 +76,4 @@ export class CallService {
data: alert,
});
}
handleFetchCalls(calls: CallHistoryItem[]) {
SendNUIMessage({
app: 'DIALER',
method: CallEvents.SET_CALL_HISTORY,
data: calls,
});
}
}