mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
* chore(phone/settings): Removed unused state * cleanup(phone/photos): Added type safety to photo state * tweak(phone/marketplace): Added type safety to marketplace state * chore(phone/match): Removed unnecessary console.log * tweak(phone/messages): Added type safety to messages state Also fixed ESLint warning for exported anonymous hook in useMessages.ts * tweak(phone/match): Added type safety to match state * tweak(phone/dialer): Cleanup & type safety for state Renamed some types to better represent their data * cleanup(phone/gen): Added NUI event enums for phone events * tweak(phone/contacts): Type safety for contacts state & variable rename Renamed and type variable in setFilteredContacts to better represent its use * tweak(phone/gen-state): Added type-safety to gen phone global state * tweak(phone/settings): Type safety for settings state * tweak(phone/photos): Tweaked type for photo referral * fix(phone/notification-comp): Fix reference to old theme config * chore(phone/hooks): Remove keyboard service Removed as this was unused and ESLint was not happy with it * chore(phone): Cleaned up eslint warnings No more warnings hooray! * tweak(phone): Set time in dev mode * fix(phone): Remove useNuiService that appeared somehow * fix(phone/gallery): Fixed missing import for gallery * Revert removing the keyboard service as this is built upon in another PR This reverts commit 82d12255a84e918da087d988b599af98ce1fe54d. * fix(phone/keyboard): Add useKeyboardService hook back to Phone.tsx * fix(phone/gallery): Fix and standardized GalleryPhoto type
130 lines
3.2 KiB
TypeScript
130 lines
3.2 KiB
TypeScript
import { CallEvents } from '../../typings/call';
|
|
import { CallHistoryItem } from '../../typings/call';
|
|
import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
|
|
|
|
const exp = (global as any).exports;
|
|
|
|
RegisterNuiCallbackType(CallEvents.INITIALIZE_CALL); // Fires when the call is started.
|
|
on(`__cfx_nui:${CallEvents.INITIALIZE_CALL}`, (data: any, cb: Function) => {
|
|
emitNet(CallEvents.INITIALIZE_CALL, data.number);
|
|
cb();
|
|
});
|
|
|
|
onNet(CallEvents.START_CALL, (transmitter: string, receiver: string, isTransmitter: boolean) => {
|
|
openCallModal(true);
|
|
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'CALL',
|
|
method: CallEvents.SET_CALLER,
|
|
data: {
|
|
active: true,
|
|
transmitter: transmitter,
|
|
receiver: receiver,
|
|
isTransmitter: isTransmitter,
|
|
accepted: false,
|
|
},
|
|
}),
|
|
);
|
|
});
|
|
|
|
RegisterNuiCallbackType(CallEvents.ACCEPT_CALL); // Fires when the TARGET accepts.
|
|
on(`__cfx_nui:${CallEvents.ACCEPT_CALL}`, (data: any, cb: Function) => {
|
|
emitNet(CallEvents.ACCEPT_CALL, data.transmitterNumber);
|
|
cb();
|
|
});
|
|
|
|
onNet(
|
|
CallEvents.WAS_ACCEPTED,
|
|
(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) => {
|
|
exp['mumble-voip'].SetCallChannel(channelId);
|
|
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'CALL',
|
|
method: CallEvents.SET_CALLER,
|
|
data: {
|
|
active: true,
|
|
transmitter: currentCall.transmitter,
|
|
receiver: currentCall.receiver,
|
|
isTransmitter: isTransmitter,
|
|
accepted: true,
|
|
},
|
|
}),
|
|
);
|
|
},
|
|
);
|
|
|
|
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
|
|
on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => {
|
|
emitNet(CallEvents.REJECTED, data.phoneNumber);
|
|
cb();
|
|
});
|
|
|
|
onNet(CallEvents.WAS_REJECTED, () => {
|
|
openCallModal(false);
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'CALL',
|
|
method: CallEvents.SET_CALLER,
|
|
data: {
|
|
transmitter: null,
|
|
receiver: null,
|
|
isTransmitter: null,
|
|
accepted: false,
|
|
active: false,
|
|
},
|
|
}),
|
|
);
|
|
});
|
|
|
|
onNet(CallEvents.SEND_HANGUP_ANIM, () => {
|
|
phoneCallEndAnim();
|
|
});
|
|
|
|
RegisterNuiCallbackType(CallEvents.END_CALL); // Fires when ending an ACTIVE call
|
|
on(`__cfx_nui:${CallEvents.END_CALL}`, (data: any, cb: Function) => {
|
|
const end = Date.now();
|
|
emitNet(CallEvents.END_CALL, data.transmitterNumber, end);
|
|
cb();
|
|
});
|
|
|
|
onNet(CallEvents.WAS_ENDED, () => {
|
|
exp['mumble-voip'].SetCallChannel(0);
|
|
openCallModal(false);
|
|
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'CALL',
|
|
method: CallEvents.SET_CALLER,
|
|
data: {
|
|
transmitter: null,
|
|
receiver: null,
|
|
isTransmitter: null,
|
|
accepted: false,
|
|
active: false,
|
|
},
|
|
}),
|
|
);
|
|
});
|
|
|
|
function openCallModal(show: boolean) {
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'CALL',
|
|
method: CallEvents.SET_CALL_MODAL,
|
|
data: show,
|
|
}),
|
|
);
|
|
}
|
|
|
|
onNet(CallEvents.SEND_HISTORY, (calls: CallHistoryItem[]) => {
|
|
SendNuiMessage(
|
|
JSON.stringify({
|
|
app: 'DIALER',
|
|
method: CallEvents.SET_CALL_HISTORY,
|
|
data: calls,
|
|
}),
|
|
);
|
|
});
|