feat(calling/client|server): partical functions for calling

Should probably reuse data
This commit is contained in:
Christopher committed 2021-01-17 22:03:52 +01:00
1 parent c12b0ba126
commit 77c7cc303e
8 files changed
+133 -56

No files matched your search

+24 -3
View File
@@ -28,6 +28,8 @@ 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';
// Inject mock data when in development env.
if (process.env.NODE_ENV === 'development') {
@@ -52,6 +54,24 @@ if (process.env.NODE_ENV === 'development') {
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'CALL',
method: 'setCaller',
data: {
accepted: false,
transmitter: false,
caller: 'Chip',
target: 'Christian',
phone_number: '860-4504',
}
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
@@ -258,6 +278,9 @@ function Phone() {
useMessagesService();
useNotesService();
usePhotoService();
useCallService();
const { modal } = useModal(); // the calling modal
const [settings] = useRecoilState(settingsState);
@@ -267,8 +290,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 +324,7 @@ function Phone() {
]}
/>
<div className='PhoneAppContainer'>
{calling ? (
{modal ? (
<CallModal />
) : (
<>
@@ -14,7 +14,7 @@ export const DialerHistory = ({ calls }) => {
return (
<List disablePadding>
{calls.map((call) => (
<ListItem key={call.id} divider>
<ListItem key={call.id} divider button>
<ListItemText primary={call.caller} secondary={call.phoneNumber} />
{CallTypeIcon[call.type]}
</ListItem>
+7
View File
@@ -0,0 +1,7 @@
export interface CallProps {
accepted: boolean;
transmitter: boolean;
caller: string;
target: string;
phone_number: string;
}
+7 -8
View File
@@ -5,39 +5,38 @@ 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 PhoneDisabledIcon from '@material-ui/icons/PhoneDisabled';
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';
export const CallModal = () => {
const { call, setCall } = useCall();
const { call } = useCall();
const { setModal } = useModal()
const [accepted, setAccepted] = useState(false)
const classes = useStyles()
const handleAcceptCall = () => {
setAccepted(true)
Nui.send('phone:acceptCall', {
phoneNumber: call.phone_number
})
}
const handleRejectCall = () => {
setModal(false)
setCall(null)
}
const handleEndCall = () => {
setModal(false)
setCall(null)
}
return (
<AppWrapper>
<AppContent>
<h1 style={{ textAlign: 'center' }}>{call.target}</h1>
<h1 style={{ textAlign: 'center' }}>{call.transmitter ? call.target : call.caller}</h1>
<div className={classes.actions}>
{!accepted ? (
{!call.accepted ? (
<>
<Fab
onClick={handleRejectCall}