Fix: Workaround for ESX errors pertaining to player loading (#153)

* Set phone ready before sending any init events + Show initializing phone message if not ready yet

* Send phone ready to nui
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-03-06 19:25:32 -05:00
1 parent 6e72e2c50e
commit 1a09fa57ae
7 files changed
+76 -31

No files matched your search

+3 -3
View File
@@ -9,8 +9,8 @@ export const phoneState = {
key: 'phoneConfig',
default: undefined,
}),
forceUpdateState: atom({
key: 'fuckingupdate',
default: 0,
phoneReady: atom({
key: 'phoneReady',
default: false,
}),
};
+3 -1
View File
@@ -10,10 +10,12 @@ interface IUsePhone {
openPhone(): void;
closePhone(): void;
isPhoneOpen: boolean;
isPhoneReady: boolean;
}
export const usePhone = (): IUsePhone => {
const isPhoneOpen = useRecoilValue(phoneState.visibility);
const isPhoneReady = useRecoilValue(phoneState.phoneReady);
const { removeAlerts } = useNotifications();
@@ -25,5 +27,5 @@ export const usePhone = (): IUsePhone => {
Nui.send('phone:open');
};
return { config: ServerConfig as any, closePhone, openPhone, isPhoneOpen };
return { config: ServerConfig as any, closePhone, openPhone, isPhoneOpen, isPhoneReady };
};
@@ -5,6 +5,8 @@ import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
export const usePhoneService = () => {
const setVisibility = useSetRecoilState(phoneState.visibility);
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
useNuiEvent('PHONE', 'setVisibility', setVisibility);
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
};