diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index 09f76cf..a387b1d 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -30,6 +30,7 @@ import config from './config/default.json'; import { useRecoilState } from 'recoil'; import { useCallService } from './modal/hooks/useCallService'; import { useModal } from './modal/hooks/useModal'; +import { useDailService } from './apps/dialer/hooks/useDailService'; // Inject mock data when in development env. if (process.env.NODE_ENV === 'development') { @@ -54,6 +55,31 @@ if (process.env.NODE_ENV === 'development') { ); }, 1000); + setTimeout(() => { + window.dispatchEvent( + new MessageEvent('message', { + data: { + app: 'DAILER', + method: 'setHistory', + data: [ + { + id: 1, + transmitter: '636-6496', + transmitterName: 'Taso Weeb', + type: 'incoming' + }, + { + id: 2, + transmitter: '777-7777', + transmitterName: 'Taso Weeb', + type: 'outgoing' + }, + ], + }, + }) + ); + }, 1000); + setTimeout(() => { window.dispatchEvent( new MessageEvent('message', { @@ -102,7 +128,7 @@ if (process.env.NODE_ENV === 'development') { { id: 1, display: 'Taso', - number: '43534444', + number: '456466', }, ], }, @@ -279,6 +305,7 @@ function Phone() { useNotesService(); usePhotoService(); useCallService(); + useDailService(); const { modal } = useModal(); // the calling modal diff --git a/phone/src/apps/contacts/components/ContactModal.tsx b/phone/src/apps/contacts/components/ContactModal.tsx index 4b26d0a..ce8b8f3 100644 --- a/phone/src/apps/contacts/components/ContactModal.tsx +++ b/phone/src/apps/contacts/components/ContactModal.tsx @@ -31,7 +31,7 @@ export const AddContactModal = () => { number, avatar, }); - console.log(name, number, avatar); + setShowModal(false) } }; diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx index 422865b..e446fb2 100644 --- a/phone/src/apps/contacts/components/List/ContactList.tsx +++ b/phone/src/apps/contacts/components/List/ContactList.tsx @@ -56,13 +56,14 @@ export const ContactList = () => { }); }; + const filteredRegEx = new RegExp(filteredContacts, "gi") + return ( {contacts.contacts .filter( (contact) => - contact.display.includes(filteredContacts.toLowerCase()) || - contact.number.includes(filteredContacts.toLowerCase()) + contact.display.match(filteredRegEx) || contact.number.match(filteredRegEx) ) .map((contact) => ( <> diff --git a/phone/src/apps/contacts/components/List/SearchContacts.tsx b/phone/src/apps/contacts/components/List/SearchContacts.tsx index 49ffe3a..2fad490 100644 --- a/phone/src/apps/contacts/components/List/SearchContacts.tsx +++ b/phone/src/apps/contacts/components/List/SearchContacts.tsx @@ -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 (
@@ -84,13 +78,13 @@ export const SearchContacts = () => {
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 }} />
diff --git a/phone/src/apps/contacts/hooks/useContacts.ts b/phone/src/apps/contacts/hooks/useContacts.ts index 471a3c5..15df383 100644 --- a/phone/src/apps/contacts/hooks/useContacts.ts +++ b/phone/src/apps/contacts/hooks/useContacts.ts @@ -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 }; }; diff --git a/phone/src/apps/contacts/hooks/useFilteredContacts.ts b/phone/src/apps/contacts/hooks/useFilteredContacts.ts index 97bb25e..b29b470 100644 --- a/phone/src/apps/contacts/hooks/useFilteredContacts.ts +++ b/phone/src/apps/contacts/hooks/useFilteredContacts.ts @@ -3,7 +3,7 @@ import { contactsState } from './state'; interface FilterdContactsProps { filteredContacts: string; - setFilteredContacts: (contact: string) => void; + setFilteredContacts: (contact: any) => void; } export const useFilteredContacts = (): FilterdContactsProps => { diff --git a/phone/src/apps/dialer/components/DialerApp.tsx b/phone/src/apps/dialer/components/DialerApp.tsx index cf81025..041e610 100644 --- a/phone/src/apps/dialer/components/DialerApp.tsx +++ b/phone/src/apps/dialer/components/DialerApp.tsx @@ -3,14 +3,16 @@ import { AppWrapper } from '../../../ui/components'; import { AppTitle } from '../../../ui/components/AppTitle'; import { AppContent } from '../../../ui/components/AppContent'; import { DialerHistory } from './views/DialerHistory'; -import { useDialerHistory } from '../hooks/useDialerHistory'; import { useApp } from '../../../os/apps/hooks/useApps'; import { Switch, Route } from 'react-router-dom'; import DialPage from './views/DialPage'; import DialerNavBar from './DialerNavBar'; +import { useDailHistory } from '../hooks/useDailHistory'; export const DialerApp = () => { - const { history } = useDialerHistory(); + + const history = useDailHistory() + const dialer = useApp('DIALER'); return ( diff --git a/phone/src/apps/dialer/components/views/DialerHistory.tsx b/phone/src/apps/dialer/components/views/DialerHistory.tsx index 6d418f1..fba5751 100644 --- a/phone/src/apps/dialer/components/views/DialerHistory.tsx +++ b/phone/src/apps/dialer/components/views/DialerHistory.tsx @@ -4,19 +4,36 @@ 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'; -const CallTypeIcon = { - incoming: , - outgoing: , -}; export const DialerHistory = ({ calls }) => { + const { number } = useSimcard(); + const { getDisplayByNumber } = useContacts(); + + const handleCall = (phoneNumber) => { + Nui.send('phone:beginCall', { + number: phoneNumber + }) + } + + if (!calls) { + return

Things are loading or arent here at all

+ } + return ( - {calls.map((call) => ( - - - {CallTypeIcon[call.type]} + {calls.map((call) => call.transmitter === number ? ( + handleCall(call.receiver)}> + + {} + + ): ( + handleCall(call.transmitter)}> + + {} ))} diff --git a/phone/src/apps/dialer/hooks/useDialerHistory.ts b/phone/src/apps/dialer/hooks/useDialerHistory.ts deleted file mode 100644 index 39e35ca..0000000 --- a/phone/src/apps/dialer/hooks/useDialerHistory.ts +++ /dev/null @@ -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 }; -};