mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
fix(calls): Fix incorrect data type being sent over net
This commit is contained in:
1 parent
60b9e35ae8
commit
5263a83d1f
10 files changed
+99
-107
No files matched your search
@@ -21,12 +21,14 @@ const useStyles = makeStyles({
|
||||
},
|
||||
});
|
||||
|
||||
export const CallModal = () => {
|
||||
export const CallModal: React.FC = () => {
|
||||
const [settings] = useSettings();
|
||||
const { call } = useCall();
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
if (!call) return null;
|
||||
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppContent
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { atom } from 'recoil';
|
||||
import { atom, useRecoilState } from 'recoil';
|
||||
import { ActiveCall } from '../../../../../typings/call';
|
||||
|
||||
export const callerState = {
|
||||
currentCall: atom<ActiveCall>({
|
||||
currentCall: atom<ActiveCall | null>({
|
||||
key: 'currentCall',
|
||||
default: null,
|
||||
}),
|
||||
@@ -15,3 +15,5 @@ export const callerState = {
|
||||
default: { ms: 0, s: 0, m: 0, h: 0 },
|
||||
}),
|
||||
};
|
||||
|
||||
export const useCurrentCall = () => useRecoilState(callerState.currentCall);
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { ActiveCall } from '../../../../../typings/call';
|
||||
import { callerState } from './state';
|
||||
import { useCurrentCall } from './state';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
import { fetchNui } from '../../../utils/fetchNui';
|
||||
import { useCallback } from 'react';
|
||||
@@ -11,7 +10,7 @@ import { ServerPromiseResp } from '../../../../../typings/common';
|
||||
|
||||
interface CallHook {
|
||||
call: ActiveCall;
|
||||
setCall: (details: any) => void;
|
||||
setCall: (call: ActiveCall) => void;
|
||||
acceptCall(): void;
|
||||
rejectCall(): void;
|
||||
endCall(): void;
|
||||
@@ -21,7 +20,7 @@ interface CallHook {
|
||||
// const TIME_TILL_AUTO_HANGUP = 15000;
|
||||
|
||||
export const useCall = (): CallHook => {
|
||||
const [call, setCall] = useRecoilState(callerState.currentCall);
|
||||
const [call, setCall] = useCurrentCall();
|
||||
// const [dialRing, setDialRing] = useState(false);
|
||||
const myPhoneNumber = useMyPhoneNumber();
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -27,12 +27,18 @@ export const useCallNotifications = () => {
|
||||
notificationIcon,
|
||||
};
|
||||
|
||||
const clearNotification = (): void => {
|
||||
removeId(NOTIFICATION_ID);
|
||||
stop();
|
||||
};
|
||||
|
||||
const setNotification = (call: ActiveCall) => {
|
||||
stop();
|
||||
if (!call || !call.active) {
|
||||
if (!call) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (call.is_accepted) {
|
||||
removeId(NOTIFICATION_ID);
|
||||
addNotification({
|
||||
@@ -70,5 +76,5 @@ export const useCallNotifications = () => {
|
||||
}
|
||||
};
|
||||
|
||||
return { setNotification };
|
||||
return { setNotification, clearNotification };
|
||||
};
|
||||
@@ -3,7 +3,6 @@ import { useSetRecoilState } from 'recoil';
|
||||
import { useCall } from './useCall';
|
||||
|
||||
import { CallEvents, ActiveCall } from '../../../../../typings/call';
|
||||
// import InjectDebugData from '../../debug/InjectDebugData';
|
||||
import { useCallModal } from './useCallModal';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { callerState } from './state';
|
||||
@@ -34,9 +33,9 @@ export const useCallService = () => {
|
||||
const history = useHistory();
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const { call, setCall } = useCall();
|
||||
const { setCall } = useCall();
|
||||
|
||||
const { setNotification } = useCallNotifications();
|
||||
const { setNotification, clearNotification } = useCallNotifications();
|
||||
|
||||
const setModal = useSetRecoilState(callerState.callModal);
|
||||
|
||||
@@ -55,10 +54,11 @@ export const useCallService = () => {
|
||||
}
|
||||
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
|
||||
|
||||
const _setCall = (_call: ActiveCall) => {
|
||||
setCall({ ...call, ..._call });
|
||||
setNotification(_call);
|
||||
};
|
||||
useNuiEvent('CALL', CallEvents.SET_CALLER, _setCall);
|
||||
useNuiEvent<ActiveCall | null>('CALL', CallEvents.SET_CALLER, (callData) => {
|
||||
setCall(callData);
|
||||
|
||||
if (!callData) return clearNotification();
|
||||
setNotification(callData);
|
||||
});
|
||||
useNuiEvent('CALL', CallEvents.SET_CALL_MODAL, setModal);
|
||||
};
|
||||
Reference in new issue
Block a user