mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
feat(phone/dialer): add contacts from dialer history
This commit is contained in:
1 parent
51fb261e8a
commit
d4fbdc8e0c
5 files changed
+70
-12
No files matched your search
@@ -45,7 +45,7 @@ InjectDebugData([
|
|||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
display: 'Chip',
|
display: 'Chip',
|
||||||
number: '417-8792',
|
number: '777-7777',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const DialerApp = () => {
|
|||||||
|
|
||||||
InjectDebugData([
|
InjectDebugData([
|
||||||
{
|
{
|
||||||
app: 'DIALER',
|
app: 'DAILER',
|
||||||
method: 'setHistory',
|
method: 'setHistory',
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
|
||||||
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
|
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
|
||||||
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
|
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
|
||||||
|
import PhoneIcon from '@material-ui/icons/Phone';
|
||||||
|
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||||
import { List } from '../../../../ui/components/List';
|
import { List } from '../../../../ui/components/List';
|
||||||
import { ListItem } from '../../../../ui/components/ListItem';
|
import { ListItem } from '../../../../ui/components/ListItem';
|
||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
@@ -10,11 +11,27 @@ import { useContacts } from '../../../contacts/hooks/useContacts';
|
|||||||
import { ICall } from '../../../../common/typings/call';
|
import { ICall } from '../../../../common/typings/call';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
|
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
callForward: {
|
||||||
|
color: theme.palette.success.main,
|
||||||
|
},
|
||||||
|
callBack: {
|
||||||
|
color: theme.palette.error.main,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
export const DialerHistory = ({ calls }) => {
|
export const DialerHistory = ({ calls }) => {
|
||||||
const { number } = useSimcard();
|
const { number } = useSimcard();
|
||||||
const { getDisplayByNumber } = useContacts();
|
const { getDisplayByNumber } = useContacts();
|
||||||
|
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleCall = (phoneNumber) => {
|
const handleCall = (phoneNumber) => {
|
||||||
@@ -23,8 +40,17 @@ export const DialerHistory = ({ calls }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!calls) {
|
if (!calls?.length) {
|
||||||
return <p>Things are loading or arent here at all</p>;
|
return (
|
||||||
|
<Box
|
||||||
|
display='flex'
|
||||||
|
justifyContent='center'
|
||||||
|
alignItems='center'
|
||||||
|
paddingTop={35}
|
||||||
|
>
|
||||||
|
<p>You got no friends!😎</p>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -34,27 +60,59 @@ export const DialerHistory = ({ calls }) => {
|
|||||||
<ListItem
|
<ListItem
|
||||||
key={call.id}
|
key={call.id}
|
||||||
divider
|
divider
|
||||||
button
|
|
||||||
onClick={() => handleCall(call.receiver)}
|
onClick={() => handleCall(call.receiver)}
|
||||||
>
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
{<PhoneForwardedIcon className={classes.callForward} />}
|
||||||
|
</ListItemIcon>
|
||||||
|
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={getDisplayByNumber(call.receiver)}
|
primary={getDisplayByNumber(call.receiver)}
|
||||||
secondary={new Date(call.start).getUTCDate()}
|
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||||
/>
|
/>
|
||||||
{<PhoneForwardedIcon />}
|
<IconButton onClick={() => handleCall(call.receiver)}>
|
||||||
|
{<PhoneIcon />}
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
<IconButton
|
||||||
|
onClick={() =>
|
||||||
|
history.push(
|
||||||
|
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{<PersonAddIcon />}
|
||||||
|
</IconButton>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
) : (
|
) : (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={call.id}
|
key={call.id}
|
||||||
divider
|
divider
|
||||||
button
|
|
||||||
onClick={() => handleCall(call.transmitter)}
|
onClick={() => handleCall(call.transmitter)}
|
||||||
>
|
>
|
||||||
|
<ListItemIcon>
|
||||||
|
{<PhoneCallbackIcon className={classes.callBack} />}
|
||||||
|
</ListItemIcon>
|
||||||
|
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary={getDisplayByNumber(call.transmitter)}
|
primary={getDisplayByNumber(call.transmitter)}
|
||||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||||
/>
|
/>
|
||||||
{<PhoneCallbackIcon />}
|
<IconButton onClick={() => handleCall(call.receiver)}>
|
||||||
|
{<PhoneIcon />}
|
||||||
|
</IconButton>
|
||||||
|
|
||||||
|
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||||
|
<IconButton
|
||||||
|
onClick={() =>
|
||||||
|
history.push(
|
||||||
|
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{<PersonAddIcon />}
|
||||||
|
</IconButton>
|
||||||
|
) : null}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ import { atom } from 'recoil';
|
|||||||
export const dialState = {
|
export const dialState = {
|
||||||
history: atom({
|
history: atom({
|
||||||
key: 'dialHistory',
|
key: 'dialHistory',
|
||||||
default: null,
|
default: [],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,7 @@ interface ICallUI {
|
|||||||
history: ICall[];
|
history: ICall[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useDialHistory = (): ICallUI => {
|
export const useDialHistory = (): ICallUI[] => {
|
||||||
const history = useRecoilValue(dialState.history);
|
const history = useRecoilValue(dialState.history);
|
||||||
return history;
|
return history;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user