mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Fix fetch on initialize (fixing notifications too) (#202)
* Fix fetch on initialize (fixing notifications too) * Add multiline support to messages input field
This commit is contained in:
1 parent
62038aa5fe
commit
e70c540ce8
4 files changed
+31
-6
No files matched your search
@@ -13,7 +13,8 @@ import { CallEvents } from '../../typings/call';
|
||||
import { MatchEvents } from '../../typings/match';
|
||||
|
||||
let isPhoneOpen = false;
|
||||
let isPhoneReady = false;
|
||||
let isPlayerReady = false;
|
||||
let isUiReady = false;
|
||||
|
||||
/* * * * * * * * * * * * *
|
||||
*
|
||||
@@ -21,11 +22,10 @@ let isPhoneReady = false;
|
||||
*
|
||||
* * * * * * * * * * * * */
|
||||
function fetchOnInitialize() {
|
||||
isPhoneReady = true;
|
||||
emitNet(ContactEvents.GET_CONTACTS);
|
||||
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
|
||||
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
|
||||
sendMessage('PHONE', 'setPhoneReady', true);
|
||||
sendMessage('PHONE', 'phoneConfig', config);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ RegisterCommand(
|
||||
* * * * * * * * * * * * */
|
||||
|
||||
async function Phone(): Promise<void> {
|
||||
fetchOnInitialize();
|
||||
if (config.PhoneAsItem) {
|
||||
// TODO: Do promise callback here
|
||||
// const hasPhoneItem = await emitNetPromise('phone:hasPhoneItem')
|
||||
@@ -111,7 +110,12 @@ async function Phone(): Promise<void> {
|
||||
}
|
||||
|
||||
// triggerd when the player is ready
|
||||
onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
|
||||
onNet(PhoneEvents.PLAYER_IS_READY, () => {
|
||||
isPlayerReady = true;
|
||||
if (isUiReady) {
|
||||
fetchOnInitialize();
|
||||
}
|
||||
});
|
||||
|
||||
AddEventHandler('onResourceStop', function (resource: string) {
|
||||
if (resource === GetCurrentResourceName()) {
|
||||
@@ -126,6 +130,15 @@ onNet('phone:sendCredentials', (number: string) => {
|
||||
sendMessage('SIMCARD', 'setNumber', number);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(PhoneEvents.UI_IS_READY);
|
||||
on(`__cfx_nui:${PhoneEvents.UI_IS_READY}`, (_data: any, cb: Function) => {
|
||||
isUiReady = true;
|
||||
if (isPlayerReady) {
|
||||
fetchOnInitialize();
|
||||
}
|
||||
cb();
|
||||
});
|
||||
|
||||
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
|
||||
// ^ AND WHAT ARE YOU GOING TO DO HUH? - KIDZ
|
||||
|
||||
|
||||
Reference in new issue
Block a user