Fix: Player ready stuff (#241)

This commit is contained in:
Christopher Gjelten authored and GitHub committed 2021-05-23 15:34:17 +02:00
1 parent a103ef9b2f
commit e05f543cb0
7 files changed
+18 -40

No files matched your search

-4
View File
@@ -10,10 +10,6 @@ export const phoneState = {
key: 'resourceConfig',
default: null,
}),
/*phoneReady: atom<boolean>({
key: 'phoneReady',
default: false,
}),*/
phoneTime: atom<string>({
key: 'phoneTime',
default: null,
-2
View File
@@ -16,7 +16,6 @@ interface IUsePhone {
export const usePhone = (): IUsePhone => {
const Nui = useNuiRequest();
const isPhoneOpen = useRecoilValue(phoneState.visibility);
//const isPhoneReady = useRecoilValue(phoneState.phoneReady);
const config = useRecoilValue(phoneState.resourceConfig);
const { removeAlerts } = useNotifications();
@@ -34,6 +33,5 @@ export const usePhone = (): IUsePhone => {
closePhone,
openPhone,
isPhoneOpen,
//isPhoneReady,
};
};
+1 -11
View File
@@ -1,22 +1,12 @@
import { useNuiEvent, useNuiRequest } from 'fivem-nui-react-lib';
import { useNuiEvent } from 'fivem-nui-react-lib';
import { useSetRecoilState } from 'recoil';
import { PhoneEvents } from '../../../../../typings/phone';
import { phoneState } from './state';
import { useEffect } from 'react';
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 setResourceConfig = useSetRecoilState(phoneState.resourceConfig);
//const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
//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);