mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(phone): fixed?
This commit is contained in:
1 parent
2f0f83a17e
commit
054f89c03d
6 files changed
+66
-25
No files matched your search
+32
-11
@@ -81,23 +81,44 @@ function Phone() {
|
|||||||
|
|
||||||
const { modal: callModal } = useCallModal();
|
const { modal: callModal } = useCallModal();
|
||||||
|
|
||||||
|
const { isPhoneReady } = usePhone();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<WindowSnackbar />
|
<WindowSnackbar />
|
||||||
<PhoneWrapper>
|
<PhoneWrapper>
|
||||||
<NotificationBar />
|
{isPhoneReady ? (
|
||||||
<div className="PhoneAppContainer">
|
|
||||||
<>
|
<>
|
||||||
<Route exact path="/" component={HomeApp} />
|
<NotificationBar />
|
||||||
{callModal && <Route exact path="/call" component={CallModal} />}
|
<div className="PhoneAppContainer">
|
||||||
{apps.map((App) => (
|
<>
|
||||||
<App.Route key={App.id} />
|
<Route exact path="/" component={HomeApp} />
|
||||||
))}
|
{callModal && <Route exact path="/call" component={CallModal} />}
|
||||||
|
{apps.map((App) => (
|
||||||
|
<App.Route key={App.id} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
<NotificationAlert />
|
||||||
|
<PhoneSnackbar />
|
||||||
|
</div>
|
||||||
|
<Navigation />
|
||||||
</>
|
</>
|
||||||
<NotificationAlert />
|
) : (
|
||||||
<PhoneSnackbar />
|
<Box
|
||||||
</div>
|
component={Paper}
|
||||||
<Navigation />
|
height="100%"
|
||||||
|
width="100%"
|
||||||
|
display="flex"
|
||||||
|
flexDirection="column"
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="center"
|
||||||
|
>
|
||||||
|
<Typography paragraph variant="h6">
|
||||||
|
NPWD {t('INITIALIZING')}
|
||||||
|
</Typography>
|
||||||
|
<Typography paragraph>{t('GENERIC_WAIT')}</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
</PhoneWrapper>
|
</PhoneWrapper>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ export const phoneState = {
|
|||||||
key: 'resourceConfig',
|
key: 'resourceConfig',
|
||||||
default: null,
|
default: null,
|
||||||
}),
|
}),
|
||||||
|
phoneReady: atom<boolean>({
|
||||||
|
key: 'phoneReady',
|
||||||
|
default: false,
|
||||||
|
}),
|
||||||
phoneTime: atom<string>({
|
phoneTime: atom<string>({
|
||||||
key: 'phoneTime',
|
key: 'phoneTime',
|
||||||
default: null,
|
default: null,
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ interface IUsePhone {
|
|||||||
openPhone(): void;
|
openPhone(): void;
|
||||||
closePhone(): void;
|
closePhone(): void;
|
||||||
isPhoneOpen: boolean;
|
isPhoneOpen: boolean;
|
||||||
|
isPhoneReady: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePhone = (): IUsePhone => {
|
export const usePhone = (): IUsePhone => {
|
||||||
const Nui = useNuiRequest();
|
const Nui = useNuiRequest();
|
||||||
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
||||||
|
const isPhoneReady = useRecoilValue(phoneState.phoneReady);
|
||||||
const config = useRecoilValue(phoneState.resourceConfig);
|
const config = useRecoilValue(phoneState.resourceConfig);
|
||||||
|
|
||||||
const { removeAlerts } = useNotifications();
|
const { removeAlerts } = useNotifications();
|
||||||
@@ -32,5 +34,6 @@ export const usePhone = (): IUsePhone => {
|
|||||||
closePhone,
|
closePhone,
|
||||||
openPhone,
|
openPhone,
|
||||||
isPhoneOpen,
|
isPhoneOpen,
|
||||||
|
isPhoneReady,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,12 +1,22 @@
|
|||||||
import { useNuiEvent } from 'fivem-nui-react-lib';
|
import { useNuiEvent, useNuiRequest } from 'fivem-nui-react-lib';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { PhoneEvents } from '../../../../../typings/phone';
|
import { PhoneEvents } from '../../../../../typings/phone';
|
||||||
import { phoneState } from './state';
|
import { phoneState } from './state';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export const usePhoneService = () => {
|
export const usePhoneService = () => {
|
||||||
|
const { send } = useNuiRequest();
|
||||||
|
|
||||||
|
// Let client know UI is ready to accept events
|
||||||
|
useEffect(() => {
|
||||||
|
send(PhoneEvents.UI_IS_READY);
|
||||||
|
}, [send]);
|
||||||
|
|
||||||
const setVisibility = useSetRecoilState(phoneState.visibility);
|
const setVisibility = useSetRecoilState(phoneState.visibility);
|
||||||
const setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
|
const setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
|
||||||
|
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||||
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||||
|
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setResourceConfig);
|
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setResourceConfig);
|
||||||
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
||||||
|
|||||||
+13
-11
@@ -21,20 +21,13 @@ let isUiReady = false;
|
|||||||
*
|
*
|
||||||
* * * * * * * * * * * * */
|
* * * * * * * * * * * * */
|
||||||
function fetchOnInitialize() {
|
function fetchOnInitialize() {
|
||||||
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
|
||||||
emitNet(ContactEvents.GET_CONTACTS);
|
emitNet(ContactEvents.GET_CONTACTS);
|
||||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||||
|
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, true);
|
||||||
|
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.general.enableMultiChar) {
|
|
||||||
on('playerSpawned', fetchOnInitialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
onNet(PhoneEvents.ON_INIT, () => {
|
|
||||||
fetchOnInitialize();
|
|
||||||
});
|
|
||||||
|
|
||||||
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
|
||||||
|
|
||||||
const getCurrentGameTime = () => {
|
const getCurrentGameTime = () => {
|
||||||
@@ -134,8 +127,17 @@ AddEventHandler('onResourceStop', function (resource: string) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
RegisterNuiCallbackType(PhoneEvents.UI_IS_READY);
|
||||||
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
on(`__cfx_nui:${PhoneEvents.UI_IS_READY}`, (_data: any, cb: Function) => {
|
||||||
|
isUiReady = true;
|
||||||
|
if (isPlayerReady) {
|
||||||
|
fetchOnInitialize();
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
|
||||||
|
onNet(PhoneEvents.ON_INIT, () => {
|
||||||
|
fetchOnInitialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ class _PlayerService {
|
|||||||
playerLogger.debug(newPlayer);
|
playerLogger.debug(newPlayer);
|
||||||
|
|
||||||
// Emit to client that player is ready
|
// Emit to client that player is ready
|
||||||
/*emitNet(PhoneEvents.ON_INIT, pSource);*/
|
console.log('init baby', pSource);
|
||||||
|
emitNet(PhoneEvents.PLAYER_IS_READY, pSource, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,7 +184,7 @@ class _PlayerService {
|
|||||||
playerLogger.debug(player);
|
playerLogger.debug(player);
|
||||||
|
|
||||||
// Emit to client that player is ready
|
// Emit to client that player is ready
|
||||||
emitNet(PhoneEvents.ON_INIT, src);
|
emitNet(PhoneEvents.PLAYER_IS_READY, src, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user