mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
fix(phone): only listen to UI Ready
This commit is contained in:
1 parent
2411c39b95
commit
fb32aaef15
6 files changed
+26
-47
No files matched your search
+16
-16
@@ -81,28 +81,28 @@ function Phone() {
|
||||
|
||||
const { modal: callModal } = useCallModal();
|
||||
|
||||
const { isPhoneReady } = usePhone();
|
||||
//const { isPhoneReady } = usePhone();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<WindowSnackbar />
|
||||
<PhoneWrapper>
|
||||
{isPhoneReady ? (
|
||||
{/*{isPhoneReady ? (
|
||||
<>*/}
|
||||
<NotificationBar />
|
||||
<div className="PhoneAppContainer">
|
||||
<>
|
||||
<NotificationBar />
|
||||
<div className="PhoneAppContainer">
|
||||
<>
|
||||
<Route exact path="/" component={HomeApp} />
|
||||
{callModal && <Route exact path="/call" component={CallModal} />}
|
||||
{apps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
</>
|
||||
<NotificationAlert />
|
||||
<PhoneSnackbar />
|
||||
</div>
|
||||
<Navigation />
|
||||
<Route exact path="/" component={HomeApp} />
|
||||
{callModal && <Route exact path="/call" component={CallModal} />}
|
||||
{apps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
</>
|
||||
<NotificationAlert />
|
||||
<PhoneSnackbar />
|
||||
</div>
|
||||
<Navigation />
|
||||
{/*</>
|
||||
) : (
|
||||
<Box
|
||||
component={Paper}
|
||||
@@ -118,7 +118,7 @@ function Phone() {
|
||||
</Typography>
|
||||
<Typography paragraph>{t('GENERIC_WAIT')}</Typography>
|
||||
</Box>
|
||||
)}
|
||||
)}*/}
|
||||
</PhoneWrapper>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -10,10 +10,10 @@ export const phoneState = {
|
||||
key: 'resourceConfig',
|
||||
default: null,
|
||||
}),
|
||||
phoneReady: atom<boolean>({
|
||||
/*phoneReady: atom<boolean>({
|
||||
key: 'phoneReady',
|
||||
default: false,
|
||||
}),
|
||||
}),*/
|
||||
phoneTime: atom<string>({
|
||||
key: 'phoneTime',
|
||||
default: null,
|
||||
|
||||
@@ -10,13 +10,13 @@ interface IUsePhone {
|
||||
openPhone(): void;
|
||||
closePhone(): void;
|
||||
isPhoneOpen: boolean;
|
||||
isPhoneReady: boolean;
|
||||
//isPhoneReady: boolean;
|
||||
}
|
||||
|
||||
export const usePhone = (): IUsePhone => {
|
||||
const Nui = useNuiRequest();
|
||||
const isPhoneOpen = useRecoilValue(phoneState.visibility);
|
||||
const isPhoneReady = useRecoilValue(phoneState.phoneReady);
|
||||
//const isPhoneReady = useRecoilValue(phoneState.phoneReady);
|
||||
const config = useRecoilValue(phoneState.resourceConfig);
|
||||
|
||||
const { removeAlerts } = useNotifications();
|
||||
@@ -34,6 +34,6 @@ export const usePhone = (): IUsePhone => {
|
||||
closePhone,
|
||||
openPhone,
|
||||
isPhoneOpen,
|
||||
isPhoneReady,
|
||||
//isPhoneReady,
|
||||
};
|
||||
};
|
||||
@@ -14,9 +14,9 @@ export const usePhoneService = () => {
|
||||
|
||||
const setVisibility = useSetRecoilState(phoneState.visibility);
|
||||
const setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
|
||||
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||
//const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
|
||||
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
||||
//useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setResourceConfig);
|
||||
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
|
||||
|
||||
@@ -12,8 +12,6 @@ import { CallEvents } from '../../typings/call';
|
||||
import { config } from './client';
|
||||
|
||||
let isPhoneOpen = false;
|
||||
let isPlayerReady = false;
|
||||
let isUiReady = false;
|
||||
|
||||
/* * * * * * * * * * * * *
|
||||
*
|
||||
@@ -24,7 +22,6 @@ function fetchOnInitialize() {
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, true);
|
||||
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
|
||||
}
|
||||
|
||||
@@ -113,14 +110,10 @@ async function Phone(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// Set the global depending on the response from event
|
||||
onNet(PhoneEvents.PLAYER_IS_READY, (ready: boolean) => {
|
||||
isPlayerReady = ready;
|
||||
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
||||
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
|
||||
});
|
||||
|
||||
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
|
||||
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number)
|
||||
})
|
||||
AddEventHandler('onResourceStop', function (resource: string) {
|
||||
if (resource === GetCurrentResourceName()) {
|
||||
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
|
||||
@@ -132,15 +125,8 @@ AddEventHandler('onResourceStop', function (resource: string) {
|
||||
|
||||
RegisterNuiCallbackType(PhoneEvents.UI_IS_READY);
|
||||
on(`__cfx_nui:${PhoneEvents.UI_IS_READY}`, (_data: any, cb: Function) => {
|
||||
isUiReady = true;
|
||||
if (isPlayerReady) {
|
||||
fetchOnInitialize();
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(PhoneEvents.ON_INIT, () => {
|
||||
fetchOnInitialize();
|
||||
cb();
|
||||
});
|
||||
|
||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||
|
||||
@@ -129,10 +129,6 @@ class _PlayerService {
|
||||
|
||||
playerLogger.info('NPWD Player Loaded!');
|
||||
playerLogger.debug(newPlayer);
|
||||
|
||||
// Emit to client that player is ready
|
||||
console.log('init baby', pSource);
|
||||
emitNet(PhoneEvents.PLAYER_IS_READY, pSource, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,9 +178,6 @@ class _PlayerService {
|
||||
|
||||
playerLogger.info(`New NPWD Player added through event (${src}) (${identifier})`);
|
||||
playerLogger.debug(player);
|
||||
|
||||
// Emit to client that player is ready
|
||||
emitNet(PhoneEvents.PLAYER_IS_READY, src, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user