mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user