mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
tweak(phone): update old NuiCallbacks with new wrapper func
Also switches old Nui.send() calls with fetchNui on focus input control
This commit is contained in:
1 parent
fc939885a8
commit
d648b21d3b
4 files changed
+23
-53
No files matched your search
@@ -1,24 +1,18 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import MUITextField from '@material-ui/core/TextField';
|
||||
import MUIInputBase, { InputBaseProps } from '@material-ui/core/InputBase';
|
||||
import { useNuiRequest } from 'fivem-nui-react-lib';
|
||||
import { PhoneEvents } from '../../../../typings/phone';
|
||||
import { TextFieldProps } from '@material-ui/core/TextField/TextField';
|
||||
import { fetchNui } from '../../utils/fetchNui';
|
||||
import { isEnvBrowser } from '../../utils/misc';
|
||||
import { noop } from '../../../../resources/utils/misc';
|
||||
|
||||
const useToggleFocus = () => {
|
||||
const Nui = useNuiRequest();
|
||||
return useCallback(
|
||||
(keepGameFocus: boolean) => {
|
||||
Nui.send(PhoneEvents.TOGGLE_KEYS, {
|
||||
keepGameFocus,
|
||||
});
|
||||
},
|
||||
[Nui],
|
||||
);
|
||||
};
|
||||
const toggleKeys = (keepGameFocus: boolean) =>
|
||||
fetchNui(PhoneEvents.TOGGLE_KEYS, {
|
||||
keepGameFocus,
|
||||
}).catch((e) => (isEnvBrowser() ? noop : console.error(e)));
|
||||
|
||||
export const TextField: React.FC<TextFieldProps> = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUITextField
|
||||
{...props}
|
||||
@@ -39,7 +33,6 @@ export const TextField: React.FC<TextFieldProps> = (props) => {
|
||||
};
|
||||
|
||||
export const InputBase: React.FC<InputBaseProps> = (props) => {
|
||||
const toggleKeys = useToggleFocus();
|
||||
return (
|
||||
<MUIInputBase
|
||||
{...props}
|
||||
|
||||
Reference in new issue
Block a user