mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
tweak(dialer): Several fixes and improvements
Time has been changed to a relative format. Locale specifics are pending merge of #168. Several typos have been fixed where "DAILER" was referenced instead of "DIALER" A translation key was added for when a user has no call history. The input box has been unlocked so users can use their keyboard directly rather than using the dial pad.
This commit is contained in:
1 parent
a6e8c769c0
commit
f1f6a05981
10 files changed
+76
-39
No files matched your search
@@ -28,7 +28,7 @@ export const DialerApp = () => {
|
||||
<Route exact path="/phone">
|
||||
<DialerHistory calls={history} />
|
||||
</Route>
|
||||
<Route path="/phone/contacts" component={ContactList}></Route>
|
||||
<Route path="/phone/contacts" component={ContactList} />
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<DialerNavBar />
|
||||
@@ -39,18 +39,18 @@ export const DialerApp = () => {
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
app: 'DAILER',
|
||||
app: 'DIALER',
|
||||
method: 'setHistory',
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
transmitter: '636-6496',
|
||||
start: 1612301545782,
|
||||
start: 1615946292,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
transmitter: '777-7777',
|
||||
start: 1612301545782,
|
||||
start: 1615946292,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ 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 PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { DialInputCtx } from '../context/InputContext';
|
||||
import { DialInputCtx, IDialInputCtx } from '../context/InputContext';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
@@ -30,7 +30,7 @@ export const DialerInput = () => {
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
|
||||
const { inputVal } = useContext(DialInputCtx);
|
||||
const { inputVal, set } = useContext<IDialInputCtx>(DialInputCtx);
|
||||
|
||||
const handleCall = (number: string) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
@@ -44,7 +44,12 @@ export const DialerInput = () => {
|
||||
|
||||
return (
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase placeholder="Enter a number" className={classes.input} value={inputVal} />
|
||||
<InputBase
|
||||
placeholder="Enter a number"
|
||||
className={classes.input}
|
||||
value={inputVal}
|
||||
onChange={(e) => set(e.target.value)}
|
||||
/>
|
||||
<IconButton color="primary" className={classes.iconBtn}>
|
||||
<PhoneIcon fontSize="large" onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
|
||||
@@ -28,6 +28,7 @@ const DialPage = () => {
|
||||
add: (val: string) => setInputVal(inputVal + val),
|
||||
removeOne: () => setInputVal(inputVal.slice(0, -1)),
|
||||
clear: () => setInputVal(''),
|
||||
set: (val: string) => setInputVal(val),
|
||||
}}
|
||||
>
|
||||
<DialerInput />
|
||||
|
||||
@@ -9,11 +9,11 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { ICall } from '../../../../../../typings/call';
|
||||
import dayjs from 'dayjs';
|
||||
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';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
callForward: {
|
||||
@@ -25,7 +25,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
}));
|
||||
|
||||
export const DialerHistory = ({ calls }) => {
|
||||
const { number } = useSimcard();
|
||||
const { number: myNumber } = useSimcard();
|
||||
const { getDisplayByNumber } = useContacts();
|
||||
|
||||
const classes = useStyles();
|
||||
@@ -44,9 +44,9 @@ export const DialerHistory = ({ calls }) => {
|
||||
return (
|
||||
<Box display="flex" justifyContent="center" alignItems="center" paddingTop={35}>
|
||||
<p>
|
||||
You got no friends!
|
||||
<span role="img" aria-label="deal with it">
|
||||
😎
|
||||
{t('APPS_DIALER_NO_HISTORY')}
|
||||
<span role="img" aria-label="sad">
|
||||
😞
|
||||
</span>
|
||||
</p>
|
||||
</Box>
|
||||
@@ -56,45 +56,57 @@ export const DialerHistory = ({ calls }) => {
|
||||
return (
|
||||
<List disablePadding>
|
||||
{calls.map((call: ICall) =>
|
||||
call.transmitter === number ? (
|
||||
call.transmitter === myNumber ? (
|
||||
<ListItem key={call.id} divider>
|
||||
<ListItemIcon>{<PhoneForwardedIcon className={classes.callForward} />}</ListItemIcon>
|
||||
<ListItemIcon>
|
||||
<PhoneForwardedIcon className={classes.callForward} />
|
||||
</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.receiver)}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
secondary={
|
||||
// TODO: Locale changes are pending #168 merge
|
||||
dayjs().to(dayjs.unix(call.start))
|
||||
}
|
||||
/>
|
||||
<IconButton onClick={() => handleCall(call.receiver)}>{<PhoneIcon />}</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter && (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`)
|
||||
}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
<PersonAddIcon />
|
||||
</IconButton>
|
||||
) : null}
|
||||
)}
|
||||
</ListItem>
|
||||
) : (
|
||||
<ListItem key={call.id} divider>
|
||||
<ListItemIcon>{<PhoneCallbackIcon className={classes.callBack} />}</ListItemIcon>
|
||||
<ListItemIcon>
|
||||
<PhoneCallbackIcon className={classes.callBack} />
|
||||
</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.transmitter)}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
secondary={
|
||||
// TODO: Locale changes are pending #168 merge
|
||||
dayjs().to(dayjs.unix(call.start))
|
||||
}
|
||||
/>
|
||||
<IconButton onClick={() => handleCall(call.transmitter)}>{<PhoneIcon />}</IconButton>
|
||||
<IconButton onClick={() => handleCall(call.transmitter)}>
|
||||
<PhoneIcon />
|
||||
</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter && (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`)
|
||||
}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
<PersonAddIcon />
|
||||
</IconButton>
|
||||
) : null}
|
||||
)}
|
||||
</ListItem>
|
||||
),
|
||||
)}
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface IDialInputCtx {
|
||||
add: (char: string | number) => void;
|
||||
removeOne: () => void;
|
||||
clear: () => void;
|
||||
set: (val) => void;
|
||||
}
|
||||
|
||||
export const DialInputCtx = createContext(null);
|
||||
@@ -1,11 +1,7 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { ICall } from '../../../../../typings/call';
|
||||
import { dialState } from './state';
|
||||
interface ICallUI {
|
||||
history: ICall[];
|
||||
}
|
||||
|
||||
export const useDialHistory = (): ICallUI[] => {
|
||||
const history = useRecoilValue(dialState.history);
|
||||
return history;
|
||||
export const useDialHistory = () => {
|
||||
return useRecoilValue<ICall[]>(dialState.history);
|
||||
};
|
||||
@@ -4,5 +4,5 @@ import { dialState } from './state';
|
||||
|
||||
export const useDialService = () => {
|
||||
const setHistory = useSetRecoilState(dialState.history);
|
||||
useNuiEvent('DAILER', 'setHistory', setHistory);
|
||||
useNuiEvent('DIALER', 'setHistory', setHistory);
|
||||
};
|
||||
Reference in new issue
Block a user