From 2cd3e9e93d4c1506ac6c6eef709929a947bc109e Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 25 Mar 2021 11:31:05 +0100 Subject: [PATCH] update dial events --- phone/src/apps/dialer/hooks/useDialService.ts | 3 ++- phone/src/os/call/hooks/useCallService.tsx | 6 +++--- resources/client/cl_call.ts | 12 ++++++------ typings/call.ts | 3 +++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/phone/src/apps/dialer/hooks/useDialService.ts b/phone/src/apps/dialer/hooks/useDialService.ts index 4e352e3..0bf2f2f 100644 --- a/phone/src/apps/dialer/hooks/useDialService.ts +++ b/phone/src/apps/dialer/hooks/useDialService.ts @@ -1,8 +1,9 @@ import { useSetRecoilState } from 'recoil'; import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; import { dialState } from './state'; +import { CallEvents } from '../../../../../typings/call'; export const useDialService = () => { const setHistory = useSetRecoilState(dialState.history); - useNuiEvent('DIALER', 'setHistory', setHistory); + useNuiEvent('DIALER', CallEvents.SET_CALL_HISTORY, setHistory); }; diff --git a/phone/src/os/call/hooks/useCallService.tsx b/phone/src/os/call/hooks/useCallService.tsx index a1085a3..3f307e8 100644 --- a/phone/src/os/call/hooks/useCallService.tsx +++ b/phone/src/os/call/hooks/useCallService.tsx @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent'; import { useSetRecoilState } from 'recoil'; import { useCall } from './useCall'; -import { CallProps } from '../../../../../typings/call'; +import { CallEvents, CallProps } from '../../../../../typings/call'; import InjectDebugData from '../../debug/InjectDebugData'; import { useCallModal } from './useCallModal'; import { useHistory, useLocation } from 'react-router-dom'; @@ -61,6 +61,6 @@ export const useCallService = () => { setCall(_call); setNotification(_call); }; - useNuiEvent('CALL', 'setCaller', _setCall, call); - useNuiEvent('CALL', 'callModal', setModal); + useNuiEvent('CALL', CallEvents.SET_CALLER, _setCall, call); + useNuiEvent('CALL', CallEvents.SET_CALL_MODAL, setModal); }; diff --git a/resources/client/cl_call.ts b/resources/client/cl_call.ts index 199e12a..671e550 100644 --- a/resources/client/cl_call.ts +++ b/resources/client/cl_call.ts @@ -16,7 +16,7 @@ onNet(CallEvents.START_CALL, (transmitter: string, receiver: string, isTransmitt SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { active: true, transmitter: transmitter, @@ -40,7 +40,7 @@ onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmi SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { active: true, transmitter: currentCall.transmitter, @@ -63,7 +63,7 @@ onNet(CallEvents.WAS_REJECTED, () => { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { transmitter: null, receiver: null, @@ -93,7 +93,7 @@ onNet(CallEvents.WAS_ENDED, () => { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'setCaller', + method: CallEvents.SET_CALLER, data: { transmitter: null, receiver: null, @@ -109,7 +109,7 @@ function openCallModal(show: boolean) { SendNuiMessage( JSON.stringify({ app: 'CALL', - method: 'callModal', + method: CallEvents.SET_CALL_MODAL, data: show, }), ); @@ -119,7 +119,7 @@ onNet(CallEvents.SEND_HISTORY, (calls: ICall) => { SendNuiMessage( JSON.stringify({ app: 'DIALER', - method: 'setHistory', + method: CallEvents.SET_CALL_HISTORY, data: calls, }), ); diff --git a/typings/call.ts b/typings/call.ts index 39f3f14..111c2a2 100644 --- a/typings/call.ts +++ b/typings/call.ts @@ -37,4 +37,7 @@ export enum CallEvents { FETCH_CALLS = 'npwd:fetchCalls', SEND_HISTORY = 'npwd:sendCallHistory', SEND_HANGUP_ANIM = 'npwd:sendHangupAnim', + SET_CALLER = 'npwd:setCaller', + SET_CALL_MODAL = 'npwd:callModal', + SET_CALL_HISTORY = 'npwd:setCallHistory', }