Merge pull request #61 from project-error/feat/calling-lua-ts

Feat/calling lua ts
This commit is contained in:
Christopher Gjelten authored and GitHub committed 2021-02-03 00:00:06 +01:00
commit 63aea89e2b
47 files changed
+1045 -182

No files matched your search

+1
View File
@@ -20,6 +20,7 @@
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^26.0.14",
"core-js": "^3.6.5",
"dayjs": "^1.10.4",
"emoji-mart": "^3.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
+50 -4
View File
@@ -28,6 +28,9 @@ import { settingsState } from './apps/settings/hooks/useSettings';
import config from './config/default.json';
import { useRecoilState } from 'recoil';
import { useCallService } from './modal/hooks/useCallService';
import { useModal } from './modal/hooks/useModal';
import { useDialService } from './apps/dialer/hooks/useDialService';
// Inject mock data when in development env.
if (process.env.NODE_ENV === 'development') {
@@ -52,6 +55,47 @@ if (process.env.NODE_ENV === 'development') {
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'DAILER',
method: 'setHistory',
data: [
{
id: 1,
transmitter: '636-6496',
start: 1612301545782,
},
{
id: 2,
transmitter: '777-7777',
start: 1612301545782,
},
],
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'CALL',
method: 'setCaller',
data: {
accepted: true,
isTransmitter: true,
transmitter: 'Chip',
receiver: 'Taso',
phone_number: '860-4504',
},
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
@@ -82,7 +126,7 @@ if (process.env.NODE_ENV === 'development') {
{
id: 1,
display: 'Taso',
number: '43534444',
number: '456466',
},
],
},
@@ -258,6 +302,10 @@ function Phone() {
useMessagesService();
useNotesService();
usePhotoService();
useCallService();
useDialService();
const { modal } = useModal(); // the calling modal
const [settings] = useRecoilState(settingsState);
@@ -267,8 +315,6 @@ function Phone() {
const currentTheme = () => createMuiTheme(config.themes[settings.theme]);
const calling = false;
document.onkeyup = function (data) {
if (data.which === 27) {
Nui.send('phone:close');
@@ -303,7 +349,7 @@ function Phone() {
]}
/>
<div className='PhoneAppContainer'>
{calling ? (
{modal ? (
<CallModal />
) : (
<>
@@ -31,7 +31,7 @@ export const AddContactModal = () => {
number,
avatar,
});
console.log(name, number, avatar);
setShowModal(false)
}
};
@@ -35,18 +35,19 @@ export const ContactList = () => {
};
const startCall = (number) => {
console.log(number);
Nui.send('phone:startCall', {
Nui.send('phone:beginCall', {
number,
});
};
const filteredRegEx = new RegExp(filteredContacts, "gi")
return (
<List>
{contacts.contacts
.filter(
(contact) =>
contact.display.includes(filteredContacts.toLowerCase()) ||
contact.number.includes(filteredContacts.toLowerCase())
contact.display.match(filteredRegEx) || contact.number.match(filteredRegEx)
)
.map((contact) => (
<>
@@ -68,15 +68,9 @@ const useStyles = makeStyles((theme: Theme) =>
export const SearchContacts = () => {
const { setFilteredContacts } = useFilteredContacts();
const classes = useStyles();
const { t } = useTranslation();
const handleChange = (e) => {
setFilteredContacts(e.target.value);
};
return (
<div className={classes.bg}>
<div className={classes.search}>
@@ -84,13 +78,13 @@ export const SearchContacts = () => {
<SearchIcon style={{ color: '#fff' }} />
</div>
<InputBase
onChange={handleChange}
onChange={e => setFilteredContacts(e.target.value)}
placeholder={t('APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS')}
classes={{
root: classes.inputRoot,
input: classes.inputInput,
}}
inputProps={{ 'aria-label': 'search' }}
inputProps={{ 'aria-label': 'search', 'autoFocus': true }}
/>
</div>
</div>
@@ -46,6 +46,7 @@ export const ContactAlert = () => {
break;
case 'CONTACT_UPDATE_SUCCESS':
setMessageAlert(alert, 'success');
break;
}
}, [alert, setMessageAlert]);
+8 -2
View File
@@ -2,13 +2,19 @@ import { useRecoilValue } from 'recoil';
import { contactsState } from './state';
import { ContactProps } from '../../../common/typings/contact';
import { useCall } from '../../../modal/hooks/useCall';
import { useCallback } from 'react';
interface IUseContacts {
contacts: ContactProps[]
getDisplayByNumber: (number: string) => string;
}
export const useContacts = (): IUseContacts => {
const contacts = useRecoilValue(contactsState.contacts);
return { contacts };
const getDisplayByNumber = useCallback((number: string) => {
const found = contacts.find((contact) => contact.number === number)
return found ? found.display : number
}, [contacts])
return { contacts, getDisplayByNumber };
};
@@ -3,7 +3,7 @@ import { contactsState } from './state';
interface FilterdContactsProps {
filteredContacts: string;
setFilteredContacts: (contact: string) => void;
setFilteredContacts: (contact: any) => void;
}
export const useFilteredContacts = (): FilterdContactsProps => {
@@ -0,0 +1,17 @@
import React from 'react';
import { Box } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) => ({
root: {
backgroundColor: '#e9e9e9',
},
}));
const ContactsSearch = () => {
const classes = useStyles();
return <Box flexGrow={1} className={classes.root}></Box>;
};
export default ContactsSearch;
@@ -0,0 +1,53 @@
import React, { useContext } from 'react';
import { Box, Button, Grid } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { DialInputCtx } from '../context/InputContext';
const useStyles = makeStyles((theme: Theme) => ({
gridItem: {
fontSize: theme.typography.h5.fontSize,
padding: theme.spacing(2),
},
}));
interface IBtnItem {
onClick?: (...args: any) => void;
label: string | number;
}
const ButtonItem = ({ label, onClick }: IBtnItem) => {
const classes = useStyles();
return (
<Grid key={label} item xs={4}>
<Button fullWidth className={classes.gridItem} onClick={onClick}>
{label}
</Button>
</Grid>
);
};
export const DialGrid = () => {
const { add, removeOne, clear} = useContext(DialInputCtx)
return (
<Box>
<Grid container justify='space-around'>
<ButtonItem label={1} onClick={() => add(1)} />
<ButtonItem label={2} onClick={() => add(2)} />
<ButtonItem label={3} onClick={() => add(3)} />
<ButtonItem label={4} onClick={() => add(4)} />
<ButtonItem label={5} onClick={() => add(5)} />
<ButtonItem label={6} onClick={() => add(6)} />
<ButtonItem label={7} onClick={() => add(7)} />
<ButtonItem label={8} onClick={() => add(8)} />
<ButtonItem label={9} onClick={() => add(9)} />
<ButtonItem label='*' onClick={clear} />
<ButtonItem label={0} onClick={() => add(0)} />
<ButtonItem label='#' onClick={removeOne} />
<ButtonItem label='-' onClick={() => add('-')} />
</Grid>
</Box>
);
};
export default DialGrid;
+17 -4
View File
@@ -2,19 +2,32 @@ import React from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
import { DialerHistory } from './DialerHistory';
import { useDialerHistory } from '../hooks/useDialerHistory';
import { DialerHistory } from './views/DialerHistory';
import { useApp } from '../../../os/apps/hooks/useApps';
import { Switch, Route } from 'react-router-dom';
import DialPage from './views/DialPage';
import DialerNavBar from './DialerNavBar';
import { useDialHistory } from '../hooks/useDialHistory';
export const DialerApp = () => {
const { history } = useDialerHistory();
const history = useDialHistory();
const dialer = useApp('DIALER');
return (
<AppWrapper>
<AppTitle app={dialer} />
<AppContent>
<DialerHistory calls={history} />
<Switch>
<Route path='/phone/dial'>
<DialPage />
</Route>
<Route path='/phone'>
<DialerHistory calls={history} />
</Route>
{/*<Route path='/phone/contacts'></Route>*/}
</Switch>
</AppContent>
<DialerNavBar />
</AppWrapper>
);
};
@@ -1,24 +0,0 @@
import React from 'react';
import ListItemText from '@material-ui/core/ListItemText';
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
import { List } from '../../../ui/components/List';
import { ListItem } from '../../../ui/components/ListItem';
const CallTypeIcon = {
incoming: <PhoneCallbackIcon />,
outgoing: <PhoneForwardedIcon />,
};
export const DialerHistory = ({ calls }) => {
return (
<List disablePadding>
{calls.map((call) => (
<ListItem key={call.id} divider>
<ListItemText primary={call.caller} secondary={call.phoneNumber} />
{CallTypeIcon[call.type]}
</ListItem>
))}
</List>
);
};
@@ -0,0 +1,50 @@
import React, { useContext } from 'react';
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import PhoneIcon from '@material-ui/icons/Phone';
import { DialInputCtx } from '../context/InputContext';
import Nui from '../../../os/nui-events/utils/Nui';
const useStyles = makeStyles((theme: Theme) => ({
root: {
textAlign: 'right',
paddingTop: theme.spacing(3),
paddingBottom: theme.spacing(3),
paddingLeft: theme.spacing(5),
paddingRight: theme.spacing(5),
display: 'flex',
height: 100,
},
input: {
flex: 1,
fontSize: theme.typography.h6.fontSize,
},
iconBtn: {
padding: 10,
},
}));
export const DialerInput = () => {
const classes = useStyles();
const { inputVal } = useContext(DialInputCtx)
const handleCall = (number: string) => {
Nui.send('phone:beginCall', {
number,
});
};
return (
<Box component={Paper} className={classes.root}>
<InputBase
placeholder='Enter a number'
className={classes.input}
value={inputVal}
/>
<IconButton className={classes.iconBtn}>
<PhoneIcon onClick={() => handleCall(inputVal)} />
</IconButton>
</Box>
);
};
@@ -0,0 +1,54 @@
import React, { ChangeEvent, useState } from 'react';
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faHome } from '@fortawesome/free-solid-svg-icons';
import AddCircleIcon from '@material-ui/icons/AddCircle';
import { Link } from 'react-router-dom';
import { makeStyles, Theme } from '@material-ui/core/styles';
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
import PhoneIcon from '@material-ui/icons/Phone';
import { History } from '@material-ui/icons';
const useStyles = makeStyles((theme: Theme) => ({
root: {
width: '100%',
backgroundColor: theme.palette.background.default,
},
icon: {
color: '#43a047',
},
}));
const DialerNavBar = () => {
const classes = useStyles();
const [page, setPage] = useState(0);
const handleChange = (event: ChangeEvent<{}>, newPage) => {
setPage(newPage);
};
return (
<BottomNavigation
value={page}
onChange={handleChange}
showLabels
className={classes.root}
>
<BottomNavigationAction
label='History'
component={Link}
icon={<History />}
to='/phone'
/>
<BottomNavigationAction
component={Link}
icon={<PhoneIcon />}
to='/phone/dial'
label='Call'
/>
</BottomNavigation>
);
};
export default DialerNavBar;
@@ -0,0 +1,39 @@
import React, { useState } from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import DialGrid from '../DialPadGrid';
import { DialerInput } from '../DialerInput';
import ContactSearch from '../ContactSearch';
import { DialInputCtx } from '../../context/InputContext';
const useStyles = makeStyles((theme: Theme) => ({
root: {
width: '100%',
minHeight: '100%',
display: 'flex',
flexDirection: 'column',
},
}));
const DialPage = () => {
const classes = useStyles();
const [inputVal, setInputVal] = useState('');
return (
<div className={classes.root}>
<DialInputCtx.Provider
value={{
inputVal,
add: (val: string) => setInputVal(inputVal + val),
removeOne: () => setInputVal(inputVal.slice(0, -1)),
clear: () => setInputVal(''),
}}
>
<ContactSearch />
<DialerInput />
<DialGrid />
</DialInputCtx.Provider>
</div>
);
};
export default DialPage;
@@ -0,0 +1,63 @@
import React from 'react';
import ListItemText from '@material-ui/core/ListItemText';
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
import { List } from '../../../../ui/components/List';
import { ListItem } from '../../../../ui/components/ListItem';
import Nui from '../../../../os/nui-events/utils/Nui';
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
import { useContacts } from '../../../contacts/hooks/useContacts';
import { ICall } from '../../../../common/typings/call';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
export const DialerHistory = ({ calls }) => {
const { number } = useSimcard();
const { getDisplayByNumber } = useContacts();
const { t } = useTranslation();
const handleCall = (phoneNumber) => {
Nui.send('phone:beginCall', {
number: phoneNumber,
});
};
if (!calls) {
return <p>Things are loading or arent here at all</p>;
}
return (
<List disablePadding>
{calls.map((call: ICall) =>
call.transmitter === number ? (
<ListItem
key={call.id}
divider
button
onClick={() => handleCall(call.receiver)}
>
<ListItemText
primary={getDisplayByNumber(call.receiver)}
secondary={new Date(call.start).getUTCDate()}
/>
{<PhoneForwardedIcon />}
</ListItem>
) : (
<ListItem
key={call.id}
divider
button
onClick={() => handleCall(call.transmitter)}
>
<ListItemText
primary={getDisplayByNumber(call.transmitter)}
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
/>
{<PhoneCallbackIcon />}
</ListItem>
)
)}
</List>
);
};
@@ -0,0 +1,10 @@
import { createContext } from 'react';
export interface IDialInputCtx {
inputVal: string;
add: (char: string | number) => void;
removeOne: () => void;
clear: () => void;
}
export const DialInputCtx = createContext(null);
+8
View File
@@ -0,0 +1,8 @@
import { atom } from 'recoil';
export const dialState = {
history: atom({
key: 'dialHistory',
default: null,
}),
};
@@ -0,0 +1,11 @@
import { useRecoilValue } from 'recoil';
import { ICall } from '../../../common/typings/call';
import { dialState } from './state';
interface ICallUI {
history: ICall[];
}
export const useDialHistory = (): ICallUI => {
const history = useRecoilValue(dialState.history);
return history;
};
@@ -0,0 +1,11 @@
import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { dialState } from './state';
import { useDialHistory } from './useDialHistory';
export const useDialService = () => {
const setHistory = useSetRecoilState(dialState.history);
useNuiEvent('DAILER', 'setHistory', setHistory);
return useDialHistory();
};
@@ -1,18 +0,0 @@
import { useRecoilState, atom } from 'recoil';
const dialerHistoryState = atom({
key: 'dialerHistory',
default: [
{
id: 1,
caller: 'ROCKY',
phoneNumber: '000-1112',
type: 'outgoing',
},
],
});
export const useDialerHistory = () => {
const [history, setHistory] = useRecoilState(dialerHistoryState);
return { history, setHistory };
};
+24
View File
@@ -0,0 +1,24 @@
export interface CallProps {
accepted: boolean;
isTransmitter: boolean;
transmitter: string;
receiver: string;
}
export interface ICall {
id?: number;
identifier: string;
transmitter: string;
transmitterSource?: number;
receiver: string;
receiverSource?: number;
start: number;
end?: number;
}
export interface ICallDuration {
ms: number;
s: number;
m: number;
h: number;
}
+5 -6
View File
@@ -2,16 +2,15 @@
"cellProvider": "AT&T",
"language": "en",
"wallpapers": [
"default.png",
"dragon.jpg",
"legacy.jpg",
"minimal.jpg",
"waves.jpg",
"surf.jpg",
"beach.jpg"
"beach.jpg",
"weeb.png",
"weeb2.gif"
],
"defaultSettings": {
"wallpaper": "default.png",
"wallpaper": "minimal.png",
"frame": "s10.png",
"theme": "taso-dark",
"zoom": "100%",
@@ -22,7 +21,7 @@
"printDebugLogs": true,
"logLevel": 1
},
"frames": ["default.png", "s10.png", "tw.png", "samsung.png"],
"frames": ["s10.png"],
"zoomOptions": ["120%", "100%", "80%", "60%", "40%"],
"ringtones": ["marimba", "pixel"],
"themes": {
+3
View File
@@ -1,5 +1,8 @@
{
"translation": {
"DATE_FORMAT": "MM/DD/YYYY",
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
"COMING_SOON": "Coming soon...",
"APPS_DIALER": "Phone",
"APPS_CONTACTS": "Contacts",
+84 -18
View File
@@ -1,29 +1,95 @@
import React from 'react';
import { green } from '@material-ui/core/colors';
import React, { useState } from 'react';
import { Button, Fab } from '@material-ui/core';
import { AppWrapper } from '../../ui/components/AppWrapper';
import { AppTitle } from '../../ui/components/AppTitle';
import { AppContent } from '../../ui/components/AppContent';
import { useCall } from '../hooks/useCall';
import CallIcon from '@material-ui/icons/Call';
import CallEndIcon from '@material-ui/icons/CallEnd';
import useStyles from './modal.styles';
import { useModal } from '../hooks/useModal';
import Nui from '../../os/nui-events/utils/Nui';
import CallTimer from './CallTimer';
export const CallModal = () => {
const { call } = useCall();
const { setModal } = useModal();
const classes = useStyles();
const handleAcceptCall = () => {
Nui.send('phone:acceptCall', {
transmitterNumber: call.transmitter,
});
};
const handleRejectCall = () => {
setModal(false);
Nui.send('phone:rejectCall', {
phoneNumber: call.transmitter,
});
};
const handleEndCall = () => {
setModal(false);
Nui.send('phone:endCall', {
transmitterNumber: call.transmitter,
});
};
if (call.isTransmitter) {
return (
<AppWrapper>
<AppContent>
<h1 style={{ textAlign: 'center' }}>{call.receiver}</h1>
<CallTimer isAccepted={call.accepted} />
<div className={classes.actions}>
<Fab
onClick={handleEndCall}
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
className={classes.actionButton}
>
<CallEndIcon />
</Fab>
</div>
</AppContent>
</AppWrapper>
);
}
return (
<AppWrapper>
<AppTitle
app={{
backgroundColor: green[400],
color: green[50],
nameLocale: 'Call',
}}
variant='h4'
/>
<AppContent>
<h1
style={{
display: 'flex',
justifyContent: 'center',
}}
>
Call
</h1>
<h1 style={{ textAlign: 'center' }}>{call.transmitter}</h1>
<CallTimer isAccepted={call.accepted} />
<div className={classes.actions}>
{!call.accepted ? (
<>
<Fab
onClick={handleRejectCall}
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
className={classes.actionButton}
>
<CallEndIcon />
</Fab>
<Fab
onClick={handleAcceptCall}
style={{ backgroundColor: '#27ae60', color: '#fff' }}
className={classes.actionButton}
>
<CallIcon />
</Fab>
</>
) : (
<Fab
onClick={handleEndCall}
style={{ backgroundColor: '#e74c3c', color: '#fff' }}
className={classes.actionButton}
>
<CallEndIcon />
</Fab>
)}
</div>
</AppContent>
</AppWrapper>
);
+63
View File
@@ -0,0 +1,63 @@
import React, { useState, useCallback, useEffect } from 'react';
import { useDuration } from '../hooks/useDuration';
function CallTimer({ isAccepted }) {
const { duration, setDuration } = useDuration();
useEffect(() => {
let timer;
if (isAccepted) {
run();
timer = setInterval(run, 10);
} else {
clearInterval(timer);
}
}, []);
let updatedMs = duration.ms,
updatedS = duration.s,
updatedM = duration.m,
updatedH = duration.h;
if (!duration) return null;
const run = () => {
if (updatedM === 60) {
updatedH++;
updatedM = 0;
}
if (updatedS === 60) {
updatedM++;
updatedS = 0;
}
if (updatedMs === 100) {
updatedS++;
updatedMs = 0;
}
updatedMs++;
return setDuration({
ms: updatedMs,
s: updatedS,
m: updatedM,
h: updatedH,
});
};
return (
<div
style={{
textAlign: 'center',
marginTop: '2em',
fontSize: 30,
}}
>
<span>{duration.h >= 10 ? duration.h : '0' + duration.h}</span>
&nbsp;:&nbsp;
<span>{duration.m >= 10 ? duration.m : '0' + duration.m}</span>
&nbsp;:&nbsp;
<span>{duration.s >= 10 ? duration.s : '0' + duration.s}</span>&nbsp;
</div>
);
}
export default CallTimer;
@@ -0,0 +1,18 @@
import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) => ({
actions: {
width: '100%',
margin: 'auto',
position: 'absolute',
display: 'flex',
alignContent: 'center',
justifyContent: 'center',
bottom: '10%',
},
actionButton: {
margin: 20,
},
}));
export default useStyles;
+11 -3
View File
@@ -1,8 +1,16 @@
import { atom } from 'recoil';
export const callerState = {
caller: atom({
key: 'callerList',
default: [],
currentCall: atom({
key: 'currentCall',
default: null
}),
callModal: atom({
key: 'callingModal',
default: false
}),
callDuration: atom({
key: 'callDuration',
default: {ms: 0, s: 0, m: 0, h: 0}
})
};
+9 -3
View File
@@ -1,7 +1,13 @@
import { useRecoilState } from 'recoil';
import { CallProps, ICallDuration } from '../../common/typings/call';
import { callerState } from './state';
export const useCall = () => {
const caller = useRecoilState(callerState.caller);
return { caller };
interface CallHook {
call: CallProps;
setCall: (details: any) => void;
}
export const useCall = (): CallHook => {
const [call, setCall] = useRecoilState(callerState.currentCall);
return { call, setCall };
};
+9 -4
View File
@@ -1,10 +1,15 @@
import { useNuiEvent } from '../../os/nui-events/hooks/useNuiEvent';
import { useSetRecoilState } from 'recoil';
import { useRecoilState, useSetRecoilState } from 'recoil';
import { callerState } from './state';
import { useCall } from './useCall';
import { useModal } from './useModal';
export const useCallService = () => {
const setCaller = useSetRecoilState(callerState.caller);
useNuiEvent('CALL', 'setCaller', setCaller);
return useCall();
const [caller, setCaller] = useRecoilState(callerState.currentCall);
const setModal = useSetRecoilState(callerState.callModal);
useNuiEvent('CALL', 'setCaller', setCaller, {}, caller);
useNuiEvent('CALL', 'callModal', setModal);
return { useCall, useModal };
};
+7
View File
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { callerState } from './state';
export const useDuration = () => {
const [duration, setDuration] = useRecoilState(callerState.callDuration);
return { duration, setDuration}
}
+12
View File
@@ -0,0 +1,12 @@
import { useRecoilState } from 'recoil';
import { callerState } from './state';
interface ModalProps {
modal: boolean;
setModal: (show: boolean) => void;
}
export const useModal = (): ModalProps => {
const [modal, setModal] = useRecoilState(callerState.callModal);
return { modal, setModal }
}
+4 -2
View File
@@ -20,7 +20,8 @@ export const useNuiEvent = (
app: string,
method: string,
handler: Function,
options: IOptions = {}
options: IOptions = {},
currentState?: Record<string, unknown>
) => {
const savedHandler: MutableRefObject<any> = useRef();
// Destructure passed options
@@ -42,7 +43,8 @@ export const useNuiEvent = (
data: event.data,
level: 1,
});
savedHandler.current(data);
const newData = currentState ? { ...currentState, ...data } : data
savedHandler.current(newData)
}
};
// Why are destructing then restructuring option data?
+5
View File
@@ -4275,6 +4275,11 @@ data-urls@^1.0.0, data-urls@^1.1.0:
whatwg-mimetype "^2.2.0"
whatwg-url "^7.0.0"
dayjs@^1.10.4:
version "1.10.4"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==
[email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"