mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(phone): fixed?
This commit is contained in:
1 parent
2f0f83a17e
commit
054f89c03d
6 files changed
+66
-25
No files matched your search
@@ -10,6 +10,10 @@ export const phoneState = {
|
||||
key: 'resourceConfig',
|
||||
default: null,
|
||||
}),
|
||||
phoneReady: atom<boolean>({
|
||||
key: 'phoneReady',
|
||||
default: false,
|
||||
}),
|
||||
phoneTime: atom<string>({
|
||||
key: 'phoneTime',
|
||||
default: null,
|
||||
|
||||
@@ -10,11 +10,13 @@ interface IUsePhone {
|
||||
openPhone(): void;
|
||||
closePhone(): void;
|
||||
isPhoneOpen: boolean;
|
||||
isPhoneReady: boolean;
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -32,5 +34,6 @@ export const usePhone = (): IUsePhone => {
|
||||
closePhone,
|
||||
openPhone,
|
||||
isPhoneOpen,
|
||||
isPhoneReady,
|
||||
};
|
||||
};
|
||||
@@ -1,12 +1,22 @@
|
||||
import { useNuiEvent } from 'fivem-nui-react-lib';
|
||||
import { useNuiEvent, useNuiRequest } 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);
|
||||
|
||||
Reference in new issue
Block a user