chore(phone): minor changes

This commit is contained in:
Christopher authored and Taso committed 2021-07-27 17:04:29 -04:00
1 parent 4e8c57492b
commit 68d2e66d16
3 files changed
+120 -93

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
export const MockHistoryData = [
{
id: 1,
identifier: 'ca839e8c-ef9d-40bd-b6a3-d531ee58149f',
transmitter: '704-1549',
receiver: '704-1549',
is_accepted: 0,
start: '1615939174',
end: null,
},
{
id: 2,
identifier: 'b8080a50-ad30-4ee9-84cb-00688e2bf167',
transmitter: '704-1549',
receiver: '704-1549',
is_accepted: 0,
start: '1615939850',
end: null,
},
];
+95 -92
View File
@@ -1,108 +1,111 @@
import { IAlertProps } from "../../../typings/alerts"; import { IAlertProps } from '../../../typings/alerts';
import { CallEvents, CallHistoryItem, CallRejectReasons } from "../../../typings/call"; import { CallEvents, CallHistoryItem, CallRejectReasons } from '../../../typings/call';
const exp = (global as any).exports; const exp = (global as any).exports;
export class CallService { export class CallService {
private currentCall: number = 0; private currentCall: number;
constructor() {
this.currentCall = 0;
}
isInCall() { isInCall() {
return this.currentCall !== 0; return this.currentCall !== 0;
} }
openCallModal(show: boolean) { openCallModal(show: boolean) {
SendNUIMessage({ SendNUIMessage({
app: 'CALL', app: 'CALL',
method: CallEvents.SET_CALL_MODAL, method: CallEvents.SET_CALL_MODAL,
data: show, data: show,
}); });
} }
handleRejectCall() { handleRejectCall() {
// we don't want to reset our UI if we're in a call already. // we don't want to reset our UI if we're in a call already.
if (this.isInCall()) return; if (this.isInCall()) return;
this.openCallModal(false); this.openCallModal(false);
SendNUIMessage({ SendNUIMessage({
app: 'CALL', app: 'CALL',
method: CallEvents.SET_CALLER, method: CallEvents.SET_CALLER,
data: { data: {
transmitter: null, transmitter: null,
receiver: null, receiver: null,
isTransmitter: null, isTransmitter: null,
accepted: false, accepted: false,
active: false, active: false,
}, },
}); });
} }
handleStartCall(transmitter: string, receiver: string, isTransmitter: boolean) { handleStartCall(transmitter: string, receiver: string, isTransmitter: boolean) {
// If we're already in a call we want to automatically reject // If we're already in a call we want to automatically reject
if (this.isInCall()) return emitNet(CallEvents.REJECTED, transmitter, CallRejectReasons.BUSY_LINE); if (this.isInCall())
this.openCallModal(true); return emitNet(CallEvents.REJECTED, transmitter, CallRejectReasons.BUSY_LINE);
this.openCallModal(true);
SendNUIMessage({ SendNUIMessage({
app: 'CALL', app: 'CALL',
method: CallEvents.SET_CALLER, method: CallEvents.SET_CALLER,
data: { data: {
active: true, active: true,
transmitter: transmitter, transmitter: transmitter,
receiver: receiver, receiver: receiver,
isTransmitter: isTransmitter, isTransmitter: isTransmitter,
accepted: false, accepted: false,
}, },
}); });
} }
handleCallAccepted(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) { handleCallAccepted(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) {
this.currentCall = channelId this.currentCall = channelId;
exp['pma-voice'].setCallChannel(channelId); exp['pma-voice'].setCallChannel(channelId);
// phoneCallStartAnim(); // Trigger call animation only if the call was accepted. // phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
SendNUIMessage({ SendNUIMessage({
app: 'CALL', app: 'CALL',
method: CallEvents.SET_CALLER, method: CallEvents.SET_CALLER,
data: { data: {
active: true, active: true,
transmitter: currentCall.transmitter, transmitter: currentCall.transmitter,
receiver: currentCall.receiver, receiver: currentCall.receiver,
isTransmitter: isTransmitter, isTransmitter: isTransmitter,
accepted: true, accepted: true,
}, },
}); });
} }
handleEndCall() { handleEndCall() {
this.currentCall = 0 this.currentCall = 0;
exp['pma-voice'].setCallChannel(0); exp['pma-voice'].setCallChannel(0);
this.openCallModal(false); this.openCallModal(false);
SendNUIMessage({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
transmitter: null,
receiver: null,
isTransmitter: null,
accepted: false,
active: false,
},
})
}
handleSendAlert(alert: IAlertProps) { SendNUIMessage({
SendNUIMessage({ app: 'CALL',
app: 'DIALER', method: CallEvents.SET_CALLER,
method: CallEvents.SEND_ALERT, data: {
data: alert, transmitter: null,
}); receiver: null,
} isTransmitter: null,
accepted: false,
active: false,
},
});
}
handleFetchCalls(calls: CallHistoryItem[]) { handleSendAlert(alert: IAlertProps) {
SendNUIMessage({ SendNUIMessage({
app: 'DIALER', app: 'DIALER',
method: CallEvents.SET_CALL_HISTORY, method: CallEvents.SEND_ALERT,
data: calls, data: alert,
}); });
} }
handleFetchCalls(calls: CallHistoryItem[]) {
SendNUIMessage({
app: 'DIALER',
method: CallEvents.SET_CALL_HISTORY,
data: calls,
});
}
} }
+5 -1
View File
@@ -131,7 +131,11 @@ class CallsService {
emitNet(CallEvents.FETCH_CALLS, src, calls); emitNet(CallEvents.FETCH_CALLS, src, calls);
} }
async handleRejectCall(src: number, transmitterNumber: string, reason: CallRejectReasons): Promise<void> { async handleRejectCall(
src: number,
transmitterNumber: string,
reason: CallRejectReasons,
): Promise<void> {
const currentCall = this.callMap.get(transmitterNumber); const currentCall = this.callMap.get(transmitterNumber);
const endCallTimeUnix = Math.floor(new Date().getTime() / 1000); const endCallTimeUnix = Math.floor(new Date().getTime() / 1000);