Author SHA1 Message Date
Darrian f3076a45fb RFR: Remove items in SQL 2021-04-01 17:21:22 -04:00
Darrian 62aaaea368 RFR: Adjust identifier length + add backticks. 2021-04-01 16:30:01 -04:00
J Francisco Rader 9896f2384e Add kiddo theme :D 2021-04-01 16:07:32 -03:00
45 changed files with 336 additions and 186 deletions

No files matched your search

+44 -46
View File
@@ -1,15 +1,13 @@
# comment this out if your server has a different table/location for phone_number # comment this out if your server has a different table/location for phone_number
# or if it already exists in the users table # or if it already exists in the users table
ALTER TABLE `users` ADD COLUMN `phone_number` VARCHAR(20) DEFAULT NULL; ALTER TABLE `users` ADD COLUMN `phone_number` VARCHAR(20) DEFAULT NULL;
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('phone', 'Phone', 1, 0, 1);
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('dphone', 'Destroyed Phone', 1, 0, 1);
CREATE TABLE IF NOT EXISTS npwd_phone_contacts ( CREATE TABLE IF NOT EXISTS `npwd_phone_contacts` (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(60) DEFAULT NULL, `identifier` varchar(48) DEFAULT NULL,
avatar varchar(512) DEFAULT NULL, `avatar` varchar(512) DEFAULT NULL,
number varchar(10) DEFAULT NULL, `number` varchar(10) DEFAULT NULL,
display varchar(60) NOT NULL DEFAULT '', `display` varchar(60) NOT NULL DEFAULT '',
PRIMARY KEY (id) PRIMARY KEY (id)
); );
@@ -19,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_tweets` (
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`likes` int NOT NULL DEFAULT '0', `likes` int NOT NULL DEFAULT '0',
`identifier` varchar(40) NOT NULL, `identifier` varchar(48) NOT NULL,
`visible` tinyint NOT NULL DEFAULT '1', `visible` tinyint NOT NULL DEFAULT '1',
`images` varchar(1000) DEFAULT '', `images` varchar(1000) DEFAULT '',
`retweet` int DEFAULT NULL, `retweet` int DEFAULT NULL,
@@ -30,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_tweets` (
CREATE TABLE IF NOT EXISTS `npwd_twitter_profiles` ( CREATE TABLE IF NOT EXISTS `npwd_twitter_profiles` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`profile_name` varchar(90) NOT NULL, `profile_name` varchar(90) NOT NULL,
`identifier` varchar(40) NOT NULL, `identifier` varchar(48) NOT NULL,
# Default Profile avatar can be set here # Default Profile avatar can be set here
`avatar_url` varchar(255) DEFAULT 'https://beta.iodine.gg/QrEvq.png', `avatar_url` varchar(255) DEFAULT 'https://beta.iodine.gg/QrEvq.png',
`bio` varchar(512) DEFAULT NULL, `bio` varchar(512) DEFAULT NULL,
@@ -56,7 +54,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_likes` (
CREATE TABLE IF NOT EXISTS `npwd_match_profiles` ( CREATE TABLE IF NOT EXISTS `npwd_match_profiles` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL, `identifier` varchar(48) NOT NULL,
`name` varchar(90) NOT NULL, `name` varchar(90) NOT NULL,
`image` varchar(255) NOT NULL, `image` varchar(255) NOT NULL,
`bio` varchar(512) DEFAULT NULL, `bio` varchar(512) DEFAULT NULL,
@@ -72,7 +70,7 @@ CREATE TABLE IF NOT EXISTS `npwd_match_profiles` (
CREATE TABLE IF NOT EXISTS `npwd_match_views` ( CREATE TABLE IF NOT EXISTS `npwd_match_views` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(40) NOT NULL, `identifier` varchar(48) NOT NULL,
`profile` int NOT NULL, `profile` int NOT NULL,
`liked` tinyint DEFAULT '0', `liked` tinyint DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -82,32 +80,32 @@ CREATE TABLE IF NOT EXISTS `npwd_match_views` (
CONSTRAINT `match_profile` FOREIGN KEY (`profile`) REFERENCES `npwd_match_profiles` (`id`) CONSTRAINT `match_profile` FOREIGN KEY (`profile`) REFERENCES `npwd_match_profiles` (`id`)
); );
CREATE TABLE IF NOT EXISTS npwd_notes ( CREATE TABLE IF NOT EXISTS `npwd_notes` (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) NOT NULL, `identifier` varchar(48) NOT NULL,
title varchar(255) NOT NULL, `title` varchar(255) NOT NULL,
content varchar(255) NOT NULL, `content` varchar(255) NOT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
CREATE TABLE IF NOT EXISTS npwd_marketplace_listings ( CREATE TABLE IF NOT EXISTS `npwd_marketplace_listings` (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL, `identifier` varchar(48) DEFAULT NULL,
username varchar(255) DEFAULT NULL, `username` varchar(255) DEFAULT NULL,
name varchar(50) DEFAULT NULL, `name` varchar(50) DEFAULT NULL,
number varchar(255) NOT NULL, `number` varchar(255) NOT NULL,
title varchar(255) DEFAULT NULL, `title` varchar(255) DEFAULT NULL,
url varchar(255) DEFAULT NULL, `url` varchar(255) DEFAULT NULL,
description varchar(255) NOT NULL, `description` varchar(255) NOT NULL,
createdAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
CREATE TABLE IF NOT EXISTS npwd_marketplace_reports ( CREATE TABLE IF NOT EXISTS `npwd_marketplace_reports` (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
listing_id int(11) DEFAULT NULL, `listing_id` int(11) DEFAULT NULL,
profile varchar(255) DEFAULT NULL, `profile` varchar(255) DEFAULT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
@@ -125,11 +123,11 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` (
CREATE TABLE IF NOT EXISTS `npwd_messages_groups` ( CREATE TABLE IF NOT EXISTS `npwd_messages_groups` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`user_identifier` varchar(40) NOT NULL, `user_identifier` varchar(48) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`group_id` varchar(512) NOT NULL, `group_id` varchar(512) NOT NULL,
`participant_identifier` varchar(40) NOT NULL, `participant_identifier` varchar(48) NOT NULL,
`label` varchar(60) DEFAULT '', `label` varchar(60) DEFAULT '',
`unreadCount` int(11) NOT NULL DEFAULT 0, `unreadCount` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@@ -137,7 +135,7 @@ CREATE TABLE IF NOT EXISTS `npwd_messages_groups` (
CREATE TABLE IF NOT EXISTS `npwd_messages_labels` ( CREATE TABLE IF NOT EXISTS `npwd_messages_labels` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`user_identifier` varchar(40) NOT NULL, `user_identifier` varchar(48) NOT NULL,
`label` varchar(60) NOT NULL, `label` varchar(60) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -148,7 +146,7 @@ CREATE TABLE IF NOT EXISTS `npwd_messages_labels` (
CREATE TABLE IF NOT EXISTS `npwd_messages` ( CREATE TABLE IF NOT EXISTS `npwd_messages` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`message` varchar(512) NOT NULL, `message` varchar(512) NOT NULL,
`user_identifier` varchar(40) NOT NULL, `user_identifier` varchar(48) NOT NULL,
`group_id` varchar(512) NOT NULL, `group_id` varchar(512) NOT NULL,
`isRead` tinyint NOT NULL DEFAULT '0', `isRead` tinyint NOT NULL DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -157,20 +155,20 @@ CREATE TABLE IF NOT EXISTS `npwd_messages` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
); );
CREATE TABLE IF NOT EXISTS npwd_calls ( CREATE TABLE IF NOT EXISTS `npwd_calls` (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL, `identifier` varchar(48) DEFAULT NULL,
transmitter varchar(255) NOT NULL, `transmitter` varchar(255) NOT NULL,
receiver varchar(255) NOT NULL, `receiver` varchar(255) NOT NULL,
is_accepted tinyint(4) DEFAULT 0, `is_accepted` tinyint(4) DEFAULT 0,
start varchar(255) DEFAULT NULL, `start` varchar(255) DEFAULT NULL,
end varchar(255) DEFAULT NULL, end varchar(255) DEFAULT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
CREATE TABLE IF NOT EXISTS npwd_phone_gallery ( CREATE TABLE IF NOT EXISTS npwd_phone_gallery (
id int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL, `identifier` varchar(48) DEFAULT NULL,
image varchar(255) DEFAULT NULL, `image` varchar(255) DEFAULT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
); );
+5 -10
View File
@@ -5,6 +5,7 @@ import { Route } from 'react-router-dom';
import { CallModal } from './os/call/components/CallModal'; import { CallModal } from './os/call/components/CallModal';
import { HomeApp } from './apps/home/components/Home'; import { HomeApp } from './apps/home/components/Home';
import { Box, Paper, Slide, Typography } from '@material-ui/core'; import { Box, Paper, Slide, Typography } from '@material-ui/core';
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
import { NotificationBar } from './os/notifications/components/NotificationBar'; import { NotificationBar } from './os/notifications/components/NotificationBar';
import { Navigation } from './os/navigation-bar/components/Navigation'; import { Navigation } from './os/navigation-bar/components/Navigation';
import { useNuiService } from './os/nui-events/hooks/useNuiService'; import { useNuiService } from './os/nui-events/hooks/useNuiService';
@@ -32,8 +33,6 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
import { usePhone } from './os/phone/hooks/usePhone'; import { usePhone } from './os/phone/hooks/usePhone';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useSnackbar } from './ui/hooks/useSnackbar'; import { useSnackbar } from './ui/hooks/useSnackbar';
import { PhoneEvents } from '../../typings/phone';
import dayjs from 'dayjs';
function Phone() { function Phone() {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
@@ -63,6 +62,7 @@ function Phone() {
}, []); }, []);
useNuiService(); useNuiService();
useKeyboardService();
usePhoneService(); usePhoneService();
useSimcardService(); useSimcardService();
useContactsService(); useContactsService();
@@ -151,20 +151,15 @@ function Phone() {
export default Phone; export default Phone;
InjectDebugData<any>([ InjectDebugData([
{ {
app: 'PHONE', app: 'PHONE',
method: PhoneEvents.SET_VISIBILITY, method: 'setVisibility',
data: true, data: true,
}, },
{ {
app: 'PHONE', app: 'PHONE',
method: PhoneEvents.SET_PHONE_READY, method: 'setPhoneReady',
data: true, data: true,
}, },
{
app: 'PHONE',
method: PhoneEvents.SET_TIME,
data: dayjs().format('hh:mm'),
},
]); ]);
@@ -7,6 +7,7 @@ import { useBankNotification } from './useBankNotification';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar'; import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { BankEvents } from '../../../../../typings/bank'; import { BankEvents } from '../../../../../typings/bank';
import { PhoneEvents } from '../../../../../typings/phone';
export const useBankService = () => { export const useBankService = () => {
const setTransaction = useSetRecoilState(bankState.transactions); const setTransaction = useSetRecoilState(bankState.transactions);
@@ -7,8 +7,9 @@ import ShareIcon from '@material-ui/icons/Share';
import Nui from '../../../../os/nui-events/utils/Nui'; import Nui from '../../../../os/nui-events/utils/Nui';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams'; import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { ICameraPhoto } from '../../hooks/usePhotos';
import { ShareModal } from './ShareModal'; import { ShareModal } from './ShareModal';
import { IPhoto, PhotoEvents } from '../../../../../../typings/photo'; import { PhotoEvents } from '../../../../../../typings/photo';
export const GalleryModal = () => { export const GalleryModal = () => {
const classes = useStyles(); const classes = useStyles();
@@ -18,9 +19,10 @@ export const GalleryModal = () => {
const [shareOpen, setShareOpen] = useState(null); const [shareOpen, setShareOpen] = useState(null);
const meta: IPhoto = useMemo(() => ({ id: parseInt(query.id), image: query.image as string }), [ const meta: ICameraPhoto = useMemo(
query, () => ({ id: query.id as string, image: query.image as string }),
]); [query],
);
const _handleClose = () => { const _handleClose = () => {
history.push(referal); history.push(referal);
@@ -5,11 +5,11 @@ import MessageIcon from '@material-ui/icons/Message';
import { setClipboard } from '../../../../os/phone/hooks/useClipboard'; import { setClipboard } from '../../../../os/phone/hooks/useClipboard';
import useStyles from './modal.styles'; import useStyles from './modal.styles';
import { ICameraPhoto } from '../../hooks/usePhotos';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { IPhoto } from '../../../../../../typings/photo';
interface IShareModalProps { interface IShareModalProps {
meta: IPhoto; meta: ICameraPhoto;
referal: string; referal: string;
onClose(): void; onClose(): void;
} }
+2 -3
View File
@@ -1,9 +1,8 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { IPhoto } from '../../../../../typings/photo';
export const photoState = { export const photoState = {
photos: atom<IPhoto[]>({ photos: atom({
key: 'galleryPhotos', key: 'galleryPhotos',
default: [], default: null,
}), }),
}; };
+7 -2
View File
@@ -1,6 +1,11 @@
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { photoState } from './state'; import { photoState } from './state';
export const usePhotos = () => { export interface ICameraPhoto {
return useRecoilValue(photoState.photos); id: string;
image: string;
}
export const usePhotos = (): ICameraPhoto[] | null => {
return useRecoilValue<ICameraPhoto[] | null>(photoState.photos);
}; };
+11 -4
View File
@@ -1,17 +1,24 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { Contact } from '../../../../../typings/contact';
export const contactsState = { export const contactsState = {
contacts: atom<Contact[]>({ contacts: atom({
key: 'contactsList', key: 'contactsList',
default: [], default: [],
}), }),
showModal: atom<boolean>({ showModal: atom({
key: 'showModal', key: 'showModal',
default: false, default: false,
}), }),
filterContacts: atom<string>({ filterContacts: atom({
key: 'filterContacts', key: 'filterContacts',
default: '', default: '',
}), }),
showContactsModal: atom({
key: 'showContactModal',
default: false,
}),
contactDetail: atom({
key: 'contactDetail',
default: null,
}),
}; };
@@ -3,7 +3,7 @@ import { contactsState } from './state';
interface FilterdContactsProps { interface FilterdContactsProps {
filteredContacts: string; filteredContacts: string;
setFilteredContacts: (searchTerm: string) => void; setFilteredContacts: (contact: any) => void;
} }
export const useFilteredContacts = (): FilterdContactsProps => { export const useFilteredContacts = (): FilterdContactsProps => {
@@ -8,7 +8,7 @@ import { ListItem } from '../../../../ui/components/ListItem';
import Nui from '../../../../os/nui-events/utils/Nui'; import Nui from '../../../../os/nui-events/utils/Nui';
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard'; import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
import { useContacts } from '../../../contacts/hooks/useContacts'; import { useContacts } from '../../../contacts/hooks/useContacts';
import { CallEvents, CallHistoryItem } from '../../../../../../typings/call'; import { CallEvents, ICall } from '../../../../../../typings/call';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core'; import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@@ -55,7 +55,7 @@ export const DialerHistory = ({ calls }) => {
return ( return (
<List disablePadding> <List disablePadding>
{calls.map((call: CallHistoryItem) => {calls.map((call: ICall) =>
call.transmitter === myNumber ? ( call.transmitter === myNumber ? (
<ListItem key={call.id} divider> <ListItem key={call.id} divider>
<ListItemIcon> <ListItemIcon>
+1 -2
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { CallHistoryItem } from '../../../../../typings/call';
export const dialState = { export const dialState = {
history: atom<CallHistoryItem[]>({ history: atom({
key: 'dialHistory', key: 'dialHistory',
default: [], default: [],
}), }),
@@ -1,6 +1,7 @@
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { ICall } from '../../../../../typings/call';
import { dialState } from './state'; import { dialState } from './state';
export const useDialHistory = () => { export const useDialHistory = () => {
return useRecoilValue(dialState.history); return useRecoilValue<ICall[]>(dialState.history);
}; };
@@ -1,5 +1,5 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { makeStyles, Button, TextField } from '@material-ui/core'; import { makeStyles, Button, TextField, Typography } from '@material-ui/core';
import Nui from '../../../../os/nui-events/utils/Nui'; import Nui from '../../../../os/nui-events/utils/Nui';
import { MarketplaceEvents } from '../../../../../../typings/marketplace'; import { MarketplaceEvents } from '../../../../../../typings/marketplace';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar'; import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
+1 -2
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { MarketplaceListing } from '../../../../../typings/marketplace';
export const selloutState = { export const selloutState = {
listing: atom<MarketplaceListing[]>({ listing: atom({
key: 'listing', key: 'listing',
default: [], default: [],
}), }),
@@ -15,6 +15,8 @@ const useStyles = makeStyles({
export function MatchBottomNavigation({ activePage, handleChange }) { export function MatchBottomNavigation({ activePage, handleChange }) {
const classes = useStyles(); const classes = useStyles();
console.log(activePage);
return ( return (
<BottomNavigation value={activePage} onChange={handleChange} className={classes.root}> <BottomNavigation value={activePage} onChange={handleChange} className={classes.root}>
<BottomNavigationAction component={Link} to="/match" icon={<HomeIcon />} /> <BottomNavigationAction component={Link} to="/match" icon={<HomeIcon />} />
+5 -6
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { FormattedMatch, FormattedProfile } from '../../../../../typings/match';
export const matchState = { export const matchState = {
profiles: atom<FormattedProfile[]>({ profiles: atom({
key: 'profiles', key: 'profiles',
default: null, default: null,
}), }),
@@ -10,19 +9,19 @@ export const matchState = {
key: 'errorLoadingProfiles', key: 'errorLoadingProfiles',
default: false, default: false,
}), }),
matches: atom<FormattedMatch[]>({ matches: atom({
key: 'matches', key: 'matches',
default: null, default: null,
}), }),
errorLoadingMatches: atom<boolean>({ errorLoadingMatches: atom({
key: 'errorLoadingMatches', key: 'errorLoadingMatches',
default: false, default: false,
}), }),
myProfile: atom<FormattedProfile | null>({ myProfile: atom({
key: 'myProfile', key: 'myProfile',
default: null, default: null,
}), }),
noProfileExists: atom<boolean>({ noProfileExists: atom({
key: 'noProfileExists', key: 'noProfileExists',
default: false, default: false,
}), }),
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Box, List } from '@material-ui/core'; import { Box, List } from '@material-ui/core';
import { MessageGroup } from '../../../../../../typings/messages'; import { MessageEvents, MessageGroup } from '../../../../../../typings/messages';
import Nui from '../../../../os/nui-events/utils/Nui';
import useMessages from '../../hooks/useMessages'; import useMessages from '../../hooks/useMessages';
import MessageGroupItem from './MessageGroupItem'; import MessageGroupItem from './MessageGroupItem';
import useStyles from './list.styles'; import useStyles from './list.styles';
+9 -10
View File
@@ -1,33 +1,32 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { CreateMessageGroupResult, Message, MessageGroup } from '../../../../../typings/messages';
export const messageState = { export const messageState = {
messageGroups: atom<MessageGroup[]>({ messageGroups: atom({
key: 'messageGroups', key: 'messageGroups',
default: [], default: null,
}), }),
messages: atom<Message[]>({ messages: atom({
key: 'messages', key: 'messages',
default: null, default: null,
}), }),
activeMessageGroup: atom<MessageGroup>({ activeMessageGroup: atom({
key: 'activeMessageGroup', key: 'activeMessageGroup',
default: null, default: null,
}), }),
showNewMessageGroup: atom<boolean>({ showNewMessageGroup: atom({
key: 'showNewMessageGroup', key: 'showNewMessageGroup',
default: false, default: false,
}), }),
createMessageGroupResult: atom<CreateMessageGroupResult>({ createMessageGroupResult: atom({
key: 'createMessageGroupResult', key: 'createMessageGroupResult',
default: null, default: null,
}), }),
imageModal: atom<boolean>({ imageModal: atom({
key: 'useImageModal', key: 'useImageModal',
default: false, default: false,
}), }),
unreadMessagesCount: atom<number>({ unreadMessagesCount: atom({
key: 'unreadMessagesCount', key: 'unreadMessagesCount',
default: 0, default: 0,
}), })
}; };
@@ -1,3 +1,4 @@
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { matchPath, useHistory } from 'react-router-dom'; import { matchPath, useHistory } from 'react-router-dom';
import { useApp } from '../../../os/apps/hooks/useApps'; import { useApp } from '../../../os/apps/hooks/useApps';
+2 -2
View File
@@ -14,7 +14,7 @@ interface IUseMessages {
activeMessageGroup: MessageGroup | null; activeMessageGroup: MessageGroup | null;
} }
export default function useMessages(): IUseMessages { export default (): IUseMessages => {
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages); const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups); const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
const [activeMessageGroup, _setActiveMessageGroup] = useRecoilState<MessageGroup | null>( const [activeMessageGroup, _setActiveMessageGroup] = useRecoilState<MessageGroup | null>(
@@ -54,4 +54,4 @@ export default function useMessages(): IUseMessages {
activeMessageGroup, activeMessageGroup,
setActiveMessageGroup, setActiveMessageGroup,
}; };
} };
@@ -10,8 +10,10 @@ import {
Tooltip, Tooltip,
Typography, Typography,
Switch, Switch,
TextField,
} from '@material-ui/core'; } from '@material-ui/core';
import CreateIcon from '@material-ui/icons/Create'; import CreateIcon from '@material-ui/icons/Create';
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
interface ISettingItem { interface ISettingItem {
options?: any; options?: any;
@@ -1,4 +1,4 @@
import React from 'react'; import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components'; import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle'; import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent'; import { AppContent } from '../../../ui/components/AppContent';
+1 -1
View File
@@ -106,7 +106,7 @@ const localStorageEffect = (key) => ({ setSelf, onSet }) => {
}); });
}; };
export const settingsState = atom<IPhoneSettings>({ export const settingsState = atom({
key: 'settings', key: 'settings',
default: config.defaultSettings, default: config.defaultSettings,
effects_UNSTABLE: [localStorageEffect(NPWD_STORAGE_KEY)], effects_UNSTABLE: [localStorageEffect(NPWD_STORAGE_KEY)],
+4
View File
@@ -191,6 +191,10 @@
{ {
"label": "Default Light", "label": "Default Light",
"value": "default-light" "value": "default-light"
},
{
"label": "Kiddo Dark",
"value": "kiddo-dark"
} }
], ],
"debug": { "debug": {
+15
View File
@@ -34,5 +34,20 @@
} }
}, },
"divider": "rgba(255, 255, 255, 0.12)" "divider": "rgba(255, 255, 255, 0.12)"
},
"kiddo-dark": {
"palette": {
"type": "dark",
"primary": {
"main": "#EBFEF3"
},
"secondary": {
"main": "#5E0035"
},
"background": {
"default": "#033A18",
"paper": "#011308"
}
}
} }
} }
+8 -1
View File
@@ -1,7 +1,13 @@
import React from 'react'; import React from 'react';
import { blue, common, grey, purple } from '@material-ui/core/colors'; import { blue, common, grey, purple } from '@material-ui/core/colors';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAd, faPlaneArrival, faPhoneAlt, faStickyNote } from '@fortawesome/free-solid-svg-icons'; import {
faAd,
faPlaneArrival,
faPhoneAlt,
faWonSign,
faStickyNote,
} from '@fortawesome/free-solid-svg-icons';
import { faTwitter } from '@fortawesome/free-brands-svg-icons'; import { faTwitter } from '@fortawesome/free-brands-svg-icons';
import ContactsIcon from '@material-ui/icons/Contacts'; import ContactsIcon from '@material-ui/icons/Contacts';
@@ -14,6 +20,7 @@ import { DialerApp } from '../../../apps/dialer/components/DialerApp';
import { ContactsApp } from '../../../apps/contacts/components/ContactsApp'; import { ContactsApp } from '../../../apps/contacts/components/ContactsApp';
import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp'; import { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
import { SettingsApp } from '../../../apps/settings/components/SettingsApp'; import { SettingsApp } from '../../../apps/settings/components/SettingsApp';
import { BankApp } from '../../../apps/bank/components/BankApp';
import { MessagesApp } from '../../../apps/messages/components/MessagesApp'; import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
import { MatchApp } from '../../../apps/match/components/MatchApp'; import { MatchApp } from '../../../apps/match/components/MatchApp';
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp'; import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
@@ -2,10 +2,10 @@ import React from 'react';
import { Box, makeStyles } from '@material-ui/core'; import { Box, makeStyles } from '@material-ui/core';
import { CallControls } from './CallControls'; import { CallControls } from './CallControls';
// interface ICallNotificationProps { interface ICallNotificationProps {
// onAccept(): void; onAccept(): void;
// onReject(): void; onReject(): void;
// } }
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
+2 -3
View File
@@ -1,12 +1,11 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { ActiveCall } from '../../../../../typings/call';
export const callerState = { export const callerState = {
currentCall: atom<ActiveCall>({ currentCall: atom({
key: 'currentCall', key: 'currentCall',
default: null, default: null,
}), }),
callModal: atom<boolean>({ callModal: atom({
key: 'callingModal', key: 'callingModal',
default: false, default: false,
}), }),
+2 -2
View File
@@ -1,11 +1,11 @@
import { useRecoilState } from 'recoil'; import { useRecoilState } from 'recoil';
import { ActiveCall } from '../../../../../typings/call'; import { CallProps } from '../../../../../typings/call';
import Nui from '../../nui-events/utils/Nui'; import Nui from '../../nui-events/utils/Nui';
import { callerState } from './state'; import { callerState } from './state';
import { CallEvents } from '../../../../../typings/call'; import { CallEvents } from '../../../../../typings/call';
interface CallHook { interface CallHook {
call: ActiveCall; call: CallProps;
setCall: (details: any) => void; setCall: (details: any) => void;
acceptCall(): void; acceptCall(): void;
rejectCall(): void; rejectCall(): void;
@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { ActiveCall } from '../../../../../typings/call'; import { CallProps } from '../../../../../typings/call';
import { useApp } from '../../apps/hooks/useApps'; import { useApp } from '../../apps/hooks/useApps';
import { useNotifications } from '../../notifications/hooks/useNotifications'; import { useNotifications } from '../../notifications/hooks/useNotifications';
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound'; import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
@@ -27,7 +27,7 @@ export const useCallNotifications = () => {
notificationIcon, notificationIcon,
}; };
const setNotification = (call: ActiveCall) => { const setNotification = (call: CallProps) => {
stop(); stop();
if (!call || !call.active) { if (!call || !call.active) {
removeId(NOTIFICATION_ID); removeId(NOTIFICATION_ID);
+4 -4
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent'; import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
import { useSetRecoilState } from 'recoil'; import { useSetRecoilState } from 'recoil';
import { useCall } from './useCall'; import { useCall } from './useCall';
import { CallEvents, ActiveCall } from '../../../../../typings/call'; import { CallEvents, CallProps } from '../../../../../typings/call';
import InjectDebugData from '../../debug/InjectDebugData'; import InjectDebugData from '../../debug/InjectDebugData';
import { useCallModal } from './useCallModal'; import { useCallModal } from './useCallModal';
import { useHistory, useLocation } from 'react-router-dom'; import { useHistory, useLocation } from 'react-router-dom';
@@ -10,7 +10,7 @@ import { callerState } from './state';
import { useCallNotifications } from './useCallNotifications'; import { useCallNotifications } from './useCallNotifications';
import { useDuration } from './useDuration'; import { useDuration } from './useDuration';
InjectDebugData<ActiveCall | boolean>([ InjectDebugData<CallProps | boolean>([
/* { /* {
app: 'CALL', app: 'CALL',
method: 'setCaller', method: 'setCaller',
@@ -56,11 +56,11 @@ export const useCallService = () => {
} }
}, [history, modal, pathname, modalHasBeenOpenedThisCall]); }, [history, modal, pathname, modalHasBeenOpenedThisCall]);
const _setCall = (_call: ActiveCall) => { const _setCall = (_call: CallProps) => {
resetDuration(); resetDuration();
setCall(_call); setCall(_call);
setNotification(_call); setNotification(_call);
}; };
useNuiEvent<ActiveCall>('CALL', CallEvents.SET_CALLER, _setCall, call); useNuiEvent<CallProps>('CALL', CallEvents.SET_CALLER, _setCall, call);
useNuiEvent<boolean>('CALL', CallEvents.SET_CALL_MODAL, setModal); useNuiEvent<boolean>('CALL', CallEvents.SET_CALL_MODAL, setModal);
}; };
@@ -0,0 +1,109 @@
import { useCallback, useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { atom, useSetRecoilState, useRecoilValue } from 'recoil';
import { usePhone } from '../../phone/hooks/usePhone';
const keyboardState = {
ArrowRight: atom({
key: 'ArrowRight',
default: null,
}),
ArrowLeft: atom({
key: 'ArrowLeft',
default: null,
}),
ArrowUp: atom({
key: 'ArrowUp',
default: null,
}),
ArrowDown: atom({
key: 'ArrowDown',
default: null,
}),
Backspace: atom({
key: 'Backspace',
default: null,
}),
Enter: atom({
key: 'Enter',
default: null,
}),
Escape: atom({
key: 'Escape',
default: null,
}),
};
const validKeys = [
'ArrowRight',
'ArrowLeft',
'ArrowUp',
'ArrowDown',
'Backspace',
'Enter',
'Escape',
];
const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
export const useKeyboardService = () => {
const history = useHistory();
const { closePhone } = usePhone();
const getters = {
ArrowRight: useRecoilValue(keyboardState.ArrowRight),
ArrowLeft: useRecoilValue(keyboardState.ArrowLeft),
ArrowUp: useRecoilValue(keyboardState.ArrowUp),
ArrowDown: useRecoilValue(keyboardState.ArrowDown),
Backspace: useRecoilValue(keyboardState.Backspace),
Enter: useRecoilValue(keyboardState.Enter),
Escape: useRecoilValue(keyboardState.Escape),
};
const handlers = useRef(new Map());
const setEscape = useSetRecoilState<any>(keyboardState.Escape);
const setBackspace = useSetRecoilState(keyboardState.Backspace);
useEffect(
function registerCustomKeys() {
Object.keys(getters).forEach((g) => {
handlers.current.set(g, getters[g]);
});
},
[getters],
);
useEffect(
function handleNUIKeyboardMessage() {
function onKeyUp(event) {
const { key } = event;
const callback = handlers.current.get(key);
if (isKeyValid(key) && callback && callback.call) {
return callback(event);
}
}
window.addEventListener('keyup', onKeyUp);
return () => window.removeEventListener('keyup', onKeyUp);
},
[getters],
);
const backspaceHandler = useCallback(
(event) => {
if (['input', 'textarea'].includes(event.target.nodeName.toLowerCase())) {
// Dont anything if we are typing something :)
return;
}
history.goBack();
},
[history],
);
useEffect(
function registerDefaultHandlers() {
handlers.current.set('Escape', () => closePhone());
handlers.current.set('Backspace', backspaceHandler);
},
[setEscape, setBackspace, history, backspaceHandler, closePhone],
);
};
+1 -3
View File
@@ -26,7 +26,7 @@ function getParams(event, data): [RequestInfo, RequestInit] {
]; ];
} }
const NuiUtils = { export default {
async send(event: any, data = {}) { async send(event: any, data = {}) {
return fetch(...getParams(event, data)); return fetch(...getParams(event, data));
}, },
@@ -34,5 +34,3 @@ const NuiUtils = {
return abortableFetch(...getParams(event, data)); return abortableFetch(...getParams(event, data));
}, },
}; };
export default NuiUtils;
+12
View File
@@ -0,0 +1,12 @@
import { atom } from 'recoil';
export const phoneSettings = {
theme: atom({
key: 'settingTheme',
default: 'default-dark',
}),
zoom: atom({
key: 'settingZoom',
default: '100%',
}),
};
+5 -6
View File
@@ -1,20 +1,19 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { IServerConfig } from '../../../../../typings/config';
export const phoneState = { export const phoneState = {
visibility: atom<boolean>({ visibility: atom({
key: 'phoneVisibility', key: 'phoneVisibility',
default: false, default: false,
}), }),
phoneConfig: atom<IServerConfig>({ phoneConfig: atom({
key: 'phoneConfig', key: 'phoneConfig',
default: null, default: undefined,
}), }),
phoneReady: atom<boolean>({ phoneReady: atom({
key: 'phoneReady', key: 'phoneReady',
default: false, default: false,
}), }),
phoneTime: atom<string>({ phoneTime: atom({
key: 'phoneTime', key: 'phoneTime',
default: null, default: null,
}), }),
+4 -5
View File
@@ -1,15 +1,14 @@
import { useSetRecoilState } from 'recoil'; import { useSetRecoilState } from 'recoil';
import { phoneState } from './state'; import { phoneState } from './state';
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent'; import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
import { PhoneEvents } from '../../../../../typings/phone';
export const usePhoneService = () => { export const usePhoneService = () => {
const setVisibility = useSetRecoilState(phoneState.visibility); const setVisibility = useSetRecoilState(phoneState.visibility);
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig); const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
const setPhoneReady = useSetRecoilState(phoneState.phoneReady); const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
const setPhoneTime = useSetRecoilState(phoneState.phoneTime); const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility); useNuiEvent('PHONE', 'setVisibility', setVisibility);
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady); useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setPhoneConfig); useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime); useNuiEvent('PHONE', 'setTime', setPhoneTime);
}; };
@@ -3,7 +3,6 @@ import { useSetRecoilState } from 'recoil';
import { simcardState } from './state'; import { simcardState } from './state';
import { useSimcard } from './useSimcard'; import { useSimcard } from './useSimcard';
import InjectDebugData from '../../debug/InjectDebugData'; import InjectDebugData from '../../debug/InjectDebugData';
import { PhoneEvents } from '../../../../../typings/phone';
InjectDebugData([ InjectDebugData([
{ {
@@ -15,6 +14,6 @@ InjectDebugData([
export const useSimcardService = () => { export const useSimcardService = () => {
const setNumber = useSetRecoilState(simcardState.number); const setNumber = useSetRecoilState(simcardState.number);
useNuiEvent('SIMCARD', PhoneEvents.SET_NUMBER, setNumber); useNuiEvent('SIMCARD', 'setNumber', setNumber);
return useSimcard(); return useSimcard();
}; };
+7 -4
View File
@@ -2,11 +2,13 @@ import React from 'react';
import Paper from '@material-ui/core/Paper'; import Paper from '@material-ui/core/Paper';
import Snackbar from '@material-ui/core/Snackbar'; import Snackbar from '@material-ui/core/Snackbar';
import Fade from '@material-ui/core/Fade'; import Fade from '@material-ui/core/Fade';
import { ThemeProvider } from '@material-ui/core'; import { createMuiTheme, ThemeProvider } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
import { usePhone } from '../../os/phone/hooks/usePhone'; import { usePhone } from '../../os/phone/hooks/usePhone';
import { usePhoneTheme } from '../../os/phone/hooks/usePhoneTheme'; import { useRecoilState } from 'recoil';
import { settingsState } from '../../apps/settings/hooks/useSettings';
import themeConfig from '../../config/default.json';
const useStyles = makeStyles({ const useStyles = makeStyles({
paper: { paper: {
@@ -23,14 +25,15 @@ function Notification({ children, handleClose, open }) {
const classes = useStyles(); const classes = useStyles();
const { config } = usePhone(); const { config } = usePhone();
const currentTheme = usePhoneTheme(); const [settings] = useRecoilState(settingsState);
if (!config) return null; if (!config) return null;
const { horizontal, vertical } = config.notificationPosition; const { horizontal, vertical } = config.notificationPosition;
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme.value]);
return ( return (
<ThemeProvider theme={currentTheme}> <ThemeProvider theme={currentTheme()}>
<Snackbar <Snackbar
className={classes.snackBar} className={classes.snackBar}
anchorOrigin={{ horizontal, vertical }} anchorOrigin={{ horizontal, vertical }}
+19 -22
View File
@@ -1,5 +1,5 @@
import { CallEvents } from '../../typings/call'; import { CallEvents } from '../../typings/call';
import { CallHistoryItem } from '../../typings/call'; import { ICall } from '../../typings/call';
import { phoneCallStartAnim, phoneCallEndAnim } from './functions'; import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
const exp = (global as any).exports; const exp = (global as any).exports;
@@ -34,26 +34,23 @@ on(`__cfx_nui:${CallEvents.ACCEPT_CALL}`, (data: any, cb: Function) => {
cb(); cb();
}); });
onNet( onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmitter: boolean) => {
CallEvents.WAS_ACCEPTED, exp['mumble-voip'].SetCallChannel(channelId);
(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) => { phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
exp['mumble-voip'].SetCallChannel(channelId); SendNuiMessage(
phoneCallStartAnim(); // Trigger call animation only if the call was accepted. JSON.stringify({
SendNuiMessage( app: 'CALL',
JSON.stringify({ method: CallEvents.SET_CALLER,
app: 'CALL', data: {
method: CallEvents.SET_CALLER, active: true,
data: { transmitter: currentCall.transmitter,
active: true, receiver: currentCall.receiver,
transmitter: currentCall.transmitter, isTransmitter: isTransmitter,
receiver: currentCall.receiver, accepted: true,
isTransmitter: isTransmitter, },
accepted: true, }),
}, );
}), });
);
},
);
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call. RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => { on(`__cfx_nui:${CallEvents.REJECTED}`, (data: any, cb: Function) => {
@@ -118,7 +115,7 @@ function openCallModal(show: boolean) {
); );
} }
onNet(CallEvents.SEND_HISTORY, (calls: CallHistoryItem[]) => { onNet(CallEvents.SEND_HISTORY, (calls: ICall) => {
SendNuiMessage( SendNuiMessage(
JSON.stringify({ JSON.stringify({
app: 'DIALER', app: 'DIALER',
+8 -8
View File
@@ -25,8 +25,8 @@ function fetchOnInitialize() {
emitNet(ContactEvents.GET_CONTACTS); emitNet(ContactEvents.GET_CONTACTS);
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS); emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE); emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, isPhoneReady); sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config); sendMessage('PHONE', 'phoneConfig', config);
} }
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1'); RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
@@ -55,14 +55,14 @@ const showPhone = async (): Promise<void> => {
await phoneOpenAnim(); // Animation starts before the phone is open await phoneOpenAnim(); // Animation starts before the phone is open
emitNet('phone:getCredentials'); emitNet('phone:getCredentials');
SetCursorLocation(0.9, 0.922); //Experimental SetCursorLocation(0.9, 0.922); //Experimental
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true); sendMessage('PHONE', 'setVisibility', true);
sendMessage('PHONE', PhoneEvents.SET_TIME, time); sendMessage('PHONE', 'setTime', time);
SetNuiFocus(true, true); SetNuiFocus(true, true);
}; };
const hidePhone = async (): Promise<void> => { const hidePhone = async (): Promise<void> => {
isPhoneOpen = false; isPhoneOpen = false;
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false); sendMessage('PHONE', 'setVisibility', false);
await phoneCloseAnim(); await phoneCloseAnim();
SetNuiFocus(false, false); SetNuiFocus(false, false);
}; };
@@ -115,15 +115,15 @@ onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
AddEventHandler('onResourceStop', function (resource: string) { AddEventHandler('onResourceStop', function (resource: string) {
if (resource === GetCurrentResourceName()) { if (resource === GetCurrentResourceName()) {
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false); sendMessage('PHONE', 'setVisibility', false);
SetNuiFocus(false, false); SetNuiFocus(false, false);
removePhoneProp(); //Deletes the phone incase it was attached. removePhoneProp(); //Deletes the phone incase it was attached.
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations. ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
} }
}); });
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => { onNet('phone:sendCredentials', (number: string) => {
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number); sendMessage('SIMCARD', 'setNumber', number);
}); });
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP // DO NOT CHANGE THIS EITHER, PLEASE - CHIP
+2 -3
View File
@@ -1,7 +1,6 @@
import { PhotoEvents } from '../../typings/photo'; import { PhotoEvents } from '../../typings/photo';
import { Delay } from '../utils/fivem'; import { Delay } from '../utils/fivem';
import { sendMessage, sendCameraEvent } from '../utils/messages'; import { sendMessage, sendCameraEvent } from '../utils/messages';
import { PhoneEvents } from '../../typings/phone';
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none'); const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
const exp = (global as any).exports; const exp = (global as any).exports;
@@ -10,12 +9,12 @@ let inCameraMode = false;
function closePhoneTemp() { function closePhoneTemp() {
SetNuiFocus(false, false); SetNuiFocus(false, false);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false); sendMessage('PHONE', 'setVisibility', false);
} }
function openPhoneTemp() { function openPhoneTemp() {
SetNuiFocus(true, true); SetNuiFocus(true, true);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true); sendMessage('PHONE', 'setVisibility', true);
} }
function CellFrontCamActivate(activate: boolean) { function CellFrontCamActivate(activate: boolean) {
+6 -6
View File
@@ -1,7 +1,7 @@
import { CallEvents } from '../../typings/call'; import { CallEvents } from '../../typings/call';
import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions'; import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
import { getPlayerFromIdentifier } from './functions'; import { getPlayerFromIdentifier } from './functions';
import { CallHistoryItem } from '../../typings/call'; import { ICall } from '../../typings/call';
import { pool } from './db'; import { pool } from './db';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
@@ -9,25 +9,25 @@ import { mainLogger } from './sv_logger';
const callLogger = mainLogger.child({ module: 'calls' }); const callLogger = mainLogger.child({ module: 'calls' });
async function saveCall(call: CallHistoryItem) { async function saveCall(call: ICall) {
const query = const query =
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)'; 'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]); await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
} }
async function updateCall(call: CallHistoryItem, isAccepted: boolean, end: number) { async function updateCall(call: ICall, isAccepted: boolean, end: number) {
const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?'; const query = 'UPDATE npwd_calls SET is_accepted=?, end=? WHERE identifier = ?';
await pool.query(query, [isAccepted, end, call.identifier]); await pool.query(query, [isAccepted, end, call.identifier]);
} }
async function fetchCalls(phoneNumber: string): Promise<CallHistoryItem[]> { async function fetchCalls(phoneNumber: string): Promise<ICall[]> {
const query = 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC'; const query = 'SELECT * FROM npwd_calls WHERE receiver = ? OR transmitter = ? ORDER BY id DESC';
const [result] = await pool.query(query, [phoneNumber, phoneNumber]); const [result] = await pool.query(query, [phoneNumber, phoneNumber]);
const calls = <CallHistoryItem[]>result; const calls = <ICall[]>result;
return calls; return calls;
} }
let calls: Map<string, CallHistoryItem> = new Map(); let calls: Map<string, ICall> = new Map();
onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => { onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
const _source = getSource(); const _source = getSource();
+1 -2
View File
@@ -1,7 +1,6 @@
import { pool } from './db'; import { pool } from './db';
import { getIdentifier, getSource } from './functions'; import { getIdentifier, getSource } from './functions';
import { mainLogger } from './sv_logger'; import { mainLogger } from './sv_logger';
import { PhoneEvents } from '../../typings/phone';
interface Credentials { interface Credentials {
phone_number: string; phone_number: string;
@@ -20,7 +19,7 @@ onNet('phone:getCredentials', async () => {
try { try {
const identifier = getIdentifier(_source); const identifier = getIdentifier(_source);
const number = await getCredentials(identifier); const number = await getCredentials(identifier);
emitNet(PhoneEvents.SEND_CREDENTIALS, _source, number); emitNet('phone:sendCredentials', _source, number);
} catch (e) { } catch (e) {
mainLogger.error(`Failed to get a number, ${e.message}`, { mainLogger.error(`Failed to get a number, ${e.message}`, {
source: _source, source: _source,
+9 -2
View File
@@ -1,4 +1,4 @@
export interface ActiveCall { export interface CallProps {
active: boolean; active: boolean;
accepted: boolean; accepted: boolean;
isTransmitter: boolean; isTransmitter: boolean;
@@ -6,7 +6,7 @@ export interface ActiveCall {
receiver: string; receiver: string;
} }
export interface CallHistoryItem { export interface ICall {
id?: number; id?: number;
identifier: string; identifier: string;
transmitter: string; transmitter: string;
@@ -18,6 +18,13 @@ export interface CallHistoryItem {
accepted: boolean; accepted: boolean;
} }
export interface ICallDuration {
ms: number;
s: number;
m: number;
h: number;
}
export enum CallEvents { export enum CallEvents {
INITIALIZE_CALL = 'npwd:beginCall', INITIALIZE_CALL = 'npwd:beginCall',
START_CALL = 'npwd:startCall', START_CALL = 'npwd:startCall',
-6
View File
@@ -11,11 +11,5 @@ export enum PhoneEvents {
OPEN_PHONE = 'npwd:open', OPEN_PHONE = 'npwd:open',
CLOSE_PHONE = 'npwd:close', CLOSE_PHONE = 'npwd:close',
SET_ALERT = 'npwd:setAlert', SET_ALERT = 'npwd:setAlert',
SET_VISIBILITY = 'npwd:setVisibility',
SET_NOTIFICATION = 'npwd:setNotification', SET_NOTIFICATION = 'npwd:setNotification',
SET_NUMBER = 'npwd:setNumber',
SET_PHONE_READY = 'npwd:phoneReady',
SET_CONFIG = 'npwd:setPhoneConfig',
SET_TIME = 'npwd:setGameTime',
SEND_CREDENTIALS = 'npwd:sendCredentials',
} }