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 337 additions and 187 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
# or if it already exists in the users table
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 (
id int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(60) DEFAULT NULL,
avatar varchar(512) DEFAULT NULL,
number varchar(10) DEFAULT NULL,
display varchar(60) NOT NULL DEFAULT '',
CREATE TABLE IF NOT EXISTS `npwd_phone_contacts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`avatar` varchar(512) DEFAULT NULL,
`number` varchar(10) DEFAULT NULL,
`display` varchar(60) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
@@ -19,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_tweets` (
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`likes` int NOT NULL DEFAULT '0',
`identifier` varchar(40) NOT NULL,
`identifier` varchar(48) NOT NULL,
`visible` tinyint NOT NULL DEFAULT '1',
`images` varchar(1000) DEFAULT '',
`retweet` int DEFAULT NULL,
@@ -30,7 +28,7 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_tweets` (
CREATE TABLE IF NOT EXISTS `npwd_twitter_profiles` (
`id` int NOT NULL AUTO_INCREMENT,
`profile_name` varchar(90) NOT NULL,
`identifier` varchar(40) NOT NULL,
`identifier` varchar(48) NOT NULL,
# Default Profile avatar can be set here
`avatar_url` varchar(255) DEFAULT 'https://beta.iodine.gg/QrEvq.png',
`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` (
`id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`identifier` varchar(48) NOT NULL,
`name` varchar(90) NOT NULL,
`image` varchar(255) NOT 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` (
`id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(40) NOT NULL,
`identifier` varchar(48) NOT NULL,
`profile` int NOT NULL,
`liked` tinyint DEFAULT '0',
`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`)
);
CREATE TABLE IF NOT EXISTS npwd_notes (
id int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) NOT NULL,
title varchar(255) NOT NULL,
content varchar(255) NOT NULL,
CREATE TABLE IF NOT EXISTS `npwd_notes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) NOT NULL,
`title` varchar(255) NOT NULL,
`content` varchar(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS npwd_marketplace_listings (
id int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL,
username varchar(255) DEFAULT NULL,
name varchar(50) DEFAULT NULL,
number varchar(255) NOT NULL,
title varchar(255) DEFAULT NULL,
url varchar(255) DEFAULT NULL,
description varchar(255) NOT NULL,
createdAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updatedAt timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CREATE TABLE IF NOT EXISTS `npwd_marketplace_listings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`number` varchar(255) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`description` varchar(255) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS npwd_marketplace_reports (
id int(11) NOT NULL AUTO_INCREMENT,
listing_id int(11) DEFAULT NULL,
profile varchar(255) DEFAULT NULL,
CREATE TABLE IF NOT EXISTS `npwd_marketplace_reports` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`listing_id` int(11) DEFAULT NULL,
`profile` varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
@@ -125,11 +123,11 @@ CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` (
CREATE TABLE IF NOT EXISTS `npwd_messages_groups` (
`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,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`group_id` varchar(512) NOT NULL,
`participant_identifier` varchar(40) NOT NULL,
`participant_identifier` varchar(48) NOT NULL,
`label` varchar(60) DEFAULT '',
`unreadCount` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
@@ -137,7 +135,7 @@ CREATE TABLE IF NOT EXISTS `npwd_messages_groups` (
CREATE TABLE IF NOT EXISTS `npwd_messages_labels` (
`id` int NOT NULL AUTO_INCREMENT,
`user_identifier` varchar(40) NOT NULL,
`user_identifier` varchar(48) NOT NULL,
`label` varchar(60) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT 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` (
`id` int NOT NULL AUTO_INCREMENT,
`message` varchar(512) NOT NULL,
`user_identifier` varchar(40) NOT NULL,
`user_identifier` varchar(48) NOT NULL,
`group_id` varchar(512) NOT NULL,
`isRead` tinyint NOT NULL DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -157,20 +155,20 @@ CREATE TABLE IF NOT EXISTS `npwd_messages` (
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS npwd_calls (
id int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL,
transmitter varchar(255) NOT NULL,
receiver varchar(255) NOT NULL,
is_accepted tinyint(4) DEFAULT 0,
start varchar(255) DEFAULT NULL,
CREATE TABLE IF NOT EXISTS `npwd_calls` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`transmitter` varchar(255) NOT NULL,
`receiver` varchar(255) NOT NULL,
`is_accepted` tinyint(4) DEFAULT 0,
`start` varchar(255) DEFAULT NULL,
end varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS npwd_phone_gallery (
id int(11) NOT NULL AUTO_INCREMENT,
identifier varchar(255) DEFAULT NULL,
image varchar(255) DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`image` varchar(255) DEFAULT NULL,
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 { HomeApp } from './apps/home/components/Home';
import { Box, Paper, Slide, Typography } from '@material-ui/core';
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
import { NotificationBar } from './os/notifications/components/NotificationBar';
import { Navigation } from './os/navigation-bar/components/Navigation';
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 { useTranslation } from 'react-i18next';
import { useSnackbar } from './ui/hooks/useSnackbar';
import { PhoneEvents } from '../../typings/phone';
import dayjs from 'dayjs';
function Phone() {
const { t, i18n } = useTranslation();
@@ -63,6 +62,7 @@ function Phone() {
}, []);
useNuiService();
useKeyboardService();
usePhoneService();
useSimcardService();
useContactsService();
@@ -151,20 +151,15 @@ function Phone() {
export default Phone;
InjectDebugData<any>([
InjectDebugData([
{
app: 'PHONE',
method: PhoneEvents.SET_VISIBILITY,
method: 'setVisibility',
data: true,
},
{
app: 'PHONE',
method: PhoneEvents.SET_PHONE_READY,
method: 'setPhoneReady',
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 { useTranslation } from 'react-i18next';
import { BankEvents } from '../../../../../typings/bank';
import { PhoneEvents } from '../../../../../typings/phone';
export const useBankService = () => {
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 { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { ICameraPhoto } from '../../hooks/usePhotos';
import { ShareModal } from './ShareModal';
import { IPhoto, PhotoEvents } from '../../../../../../typings/photo';
import { PhotoEvents } from '../../../../../../typings/photo';
export const GalleryModal = () => {
const classes = useStyles();
@@ -18,9 +19,10 @@ export const GalleryModal = () => {
const [shareOpen, setShareOpen] = useState(null);
const meta: IPhoto = useMemo(() => ({ id: parseInt(query.id), image: query.image as string }), [
query,
]);
const meta: ICameraPhoto = useMemo(
() => ({ id: query.id as string, image: query.image as string }),
[query],
);
const _handleClose = () => {
history.push(referal);
@@ -5,11 +5,11 @@ import MessageIcon from '@material-ui/icons/Message';
import { setClipboard } from '../../../../os/phone/hooks/useClipboard';
import useStyles from './modal.styles';
import { ICameraPhoto } from '../../hooks/usePhotos';
import { useHistory } from 'react-router-dom';
import { IPhoto } from '../../../../../../typings/photo';
interface IShareModalProps {
meta: IPhoto;
meta: ICameraPhoto;
referal: string;
onClose(): void;
}
+2 -3
View File
@@ -1,9 +1,8 @@
import { atom } from 'recoil';
import { IPhoto } from '../../../../../typings/photo';
export const photoState = {
photos: atom<IPhoto[]>({
photos: atom({
key: 'galleryPhotos',
default: [],
default: null,
}),
};
+7 -2
View File
@@ -1,6 +1,11 @@
import { useRecoilValue } from 'recoil';
import { photoState } from './state';
export const usePhotos = () => {
return useRecoilValue(photoState.photos);
export interface ICameraPhoto {
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 { Contact } from '../../../../../typings/contact';
export const contactsState = {
contacts: atom<Contact[]>({
contacts: atom({
key: 'contactsList',
default: [],
}),
showModal: atom<boolean>({
showModal: atom({
key: 'showModal',
default: false,
}),
filterContacts: atom<string>({
filterContacts: atom({
key: 'filterContacts',
default: '',
}),
showContactsModal: atom({
key: 'showContactModal',
default: false,
}),
contactDetail: atom({
key: 'contactDetail',
default: null,
}),
};
@@ -3,7 +3,7 @@ import { contactsState } from './state';
interface FilterdContactsProps {
filteredContacts: string;
setFilteredContacts: (searchTerm: string) => void;
setFilteredContacts: (contact: any) => void;
}
export const useFilteredContacts = (): FilterdContactsProps => {
@@ -8,7 +8,7 @@ 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';
import { CallEvents, CallHistoryItem } from '../../../../../../typings/call';
import { CallEvents, ICall } from '../../../../../../typings/call';
import { useTranslation } from 'react-i18next';
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
import { useHistory } from 'react-router-dom';
@@ -55,7 +55,7 @@ export const DialerHistory = ({ calls }) => {
return (
<List disablePadding>
{calls.map((call: CallHistoryItem) =>
{calls.map((call: ICall) =>
call.transmitter === myNumber ? (
<ListItem key={call.id} divider>
<ListItemIcon>
+1 -2
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil';
import { CallHistoryItem } from '../../../../../typings/call';
export const dialState = {
history: atom<CallHistoryItem[]>({
history: atom({
key: 'dialHistory',
default: [],
}),
@@ -1,6 +1,7 @@
import { useRecoilValue } from 'recoil';
import { ICall } from '../../../../../typings/call';
import { dialState } from './state';
export const useDialHistory = () => {
return useRecoilValue(dialState.history);
return useRecoilValue<ICall[]>(dialState.history);
};
@@ -1,5 +1,5 @@
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 { MarketplaceEvents } from '../../../../../../typings/marketplace';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
+1 -2
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil';
import { MarketplaceListing } from '../../../../../typings/marketplace';
export const selloutState = {
listing: atom<MarketplaceListing[]>({
listing: atom({
key: 'listing',
default: [],
}),
@@ -15,6 +15,8 @@ const useStyles = makeStyles({
export function MatchBottomNavigation({ activePage, handleChange }) {
const classes = useStyles();
console.log(activePage);
return (
<BottomNavigation value={activePage} onChange={handleChange} className={classes.root}>
<BottomNavigationAction component={Link} to="/match" icon={<HomeIcon />} />
+5 -6
View File
@@ -1,8 +1,7 @@
import { atom } from 'recoil';
import { FormattedMatch, FormattedProfile } from '../../../../../typings/match';
export const matchState = {
profiles: atom<FormattedProfile[]>({
profiles: atom({
key: 'profiles',
default: null,
}),
@@ -10,19 +9,19 @@ export const matchState = {
key: 'errorLoadingProfiles',
default: false,
}),
matches: atom<FormattedMatch[]>({
matches: atom({
key: 'matches',
default: null,
}),
errorLoadingMatches: atom<boolean>({
errorLoadingMatches: atom({
key: 'errorLoadingMatches',
default: false,
}),
myProfile: atom<FormattedProfile | null>({
myProfile: atom({
key: 'myProfile',
default: null,
}),
noProfileExists: atom<boolean>({
noProfileExists: atom({
key: 'noProfileExists',
default: false,
}),
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from 'react';
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 MessageGroupItem from './MessageGroupItem';
import useStyles from './list.styles';
+9 -10
View File
@@ -1,33 +1,32 @@
import { atom } from 'recoil';
import { CreateMessageGroupResult, Message, MessageGroup } from '../../../../../typings/messages';
export const messageState = {
messageGroups: atom<MessageGroup[]>({
messageGroups: atom({
key: 'messageGroups',
default: [],
default: null,
}),
messages: atom<Message[]>({
messages: atom({
key: 'messages',
default: null,
}),
activeMessageGroup: atom<MessageGroup>({
activeMessageGroup: atom({
key: 'activeMessageGroup',
default: null,
}),
showNewMessageGroup: atom<boolean>({
showNewMessageGroup: atom({
key: 'showNewMessageGroup',
default: false,
}),
createMessageGroupResult: atom<CreateMessageGroupResult>({
createMessageGroupResult: atom({
key: 'createMessageGroupResult',
default: null,
}),
imageModal: atom<boolean>({
imageModal: atom({
key: 'useImageModal',
default: false,
}),
unreadMessagesCount: atom<number>({
unreadMessagesCount: atom({
key: 'unreadMessagesCount',
default: 0,
}),
})
};
@@ -1,3 +1,4 @@
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { matchPath, useHistory } from 'react-router-dom';
import { useApp } from '../../../os/apps/hooks/useApps';
+2 -2
View File
@@ -14,7 +14,7 @@ interface IUseMessages {
activeMessageGroup: MessageGroup | null;
}
export default function useMessages(): IUseMessages {
export default (): IUseMessages => {
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
const [activeMessageGroup, _setActiveMessageGroup] = useRecoilState<MessageGroup | null>(
@@ -54,4 +54,4 @@ export default function useMessages(): IUseMessages {
activeMessageGroup,
setActiveMessageGroup,
};
}
};
@@ -10,8 +10,10 @@ import {
Tooltip,
Typography,
Switch,
TextField,
} from '@material-ui/core';
import CreateIcon from '@material-ui/icons/Create';
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
interface ISettingItem {
options?: any;
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
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',
default: config.defaultSettings,
effects_UNSTABLE: [localStorageEffect(NPWD_STORAGE_KEY)],
+4
View File
@@ -191,6 +191,10 @@
{
"label": "Default Light",
"value": "default-light"
},
{
"label": "Kiddo Dark",
"value": "kiddo-dark"
}
],
"debug": {
+16 -1
View File
@@ -34,5 +34,20 @@
}
},
"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 { blue, common, grey, purple } from '@material-ui/core/colors';
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 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 { CalculatorApp } from '../../../apps/calculator/components/CalculatorApp';
import { SettingsApp } from '../../../apps/settings/components/SettingsApp';
import { BankApp } from '../../../apps/bank/components/BankApp';
import { MessagesApp } from '../../../apps/messages/components/MessagesApp';
import { MatchApp } from '../../../apps/match/components/MatchApp';
import { TwitterApp } from '../../../apps/twitter/components/TwitterApp';
@@ -2,10 +2,10 @@ import React from 'react';
import { Box, makeStyles } from '@material-ui/core';
import { CallControls } from './CallControls';
// interface ICallNotificationProps {
// onAccept(): void;
// onReject(): void;
// }
interface ICallNotificationProps {
onAccept(): void;
onReject(): void;
}
const useStyles = makeStyles((theme) => ({
root: {
+2 -3
View File
@@ -1,12 +1,11 @@
import { atom } from 'recoil';
import { ActiveCall } from '../../../../../typings/call';
export const callerState = {
currentCall: atom<ActiveCall>({
currentCall: atom({
key: 'currentCall',
default: null,
}),
callModal: atom<boolean>({
callModal: atom({
key: 'callingModal',
default: false,
}),
+2 -2
View File
@@ -1,11 +1,11 @@
import { useRecoilState } from 'recoil';
import { ActiveCall } from '../../../../../typings/call';
import { CallProps } from '../../../../../typings/call';
import Nui from '../../nui-events/utils/Nui';
import { callerState } from './state';
import { CallEvents } from '../../../../../typings/call';
interface CallHook {
call: ActiveCall;
call: CallProps;
setCall: (details: any) => void;
acceptCall(): void;
rejectCall(): void;
@@ -1,7 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { ActiveCall } from '../../../../../typings/call';
import { CallProps } from '../../../../../typings/call';
import { useApp } from '../../apps/hooks/useApps';
import { useNotifications } from '../../notifications/hooks/useNotifications';
import { useRingtoneSound } from '../../sound/hooks/useRingtoneSound';
@@ -27,7 +27,7 @@ export const useCallNotifications = () => {
notificationIcon,
};
const setNotification = (call: ActiveCall) => {
const setNotification = (call: CallProps) => {
stop();
if (!call || !call.active) {
removeId(NOTIFICATION_ID);
+4 -4
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
import { useSetRecoilState } from 'recoil';
import { useCall } from './useCall';
import { CallEvents, ActiveCall } from '../../../../../typings/call';
import { CallEvents, CallProps } from '../../../../../typings/call';
import InjectDebugData from '../../debug/InjectDebugData';
import { useCallModal } from './useCallModal';
import { useHistory, useLocation } from 'react-router-dom';
@@ -10,7 +10,7 @@ import { callerState } from './state';
import { useCallNotifications } from './useCallNotifications';
import { useDuration } from './useDuration';
InjectDebugData<ActiveCall | boolean>([
InjectDebugData<CallProps | boolean>([
/* {
app: 'CALL',
method: 'setCaller',
@@ -56,11 +56,11 @@ export const useCallService = () => {
}
}, [history, modal, pathname, modalHasBeenOpenedThisCall]);
const _setCall = (_call: ActiveCall) => {
const _setCall = (_call: CallProps) => {
resetDuration();
setCall(_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);
};
@@ -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 = {}) {
return fetch(...getParams(event, data));
},
@@ -34,5 +34,3 @@ const NuiUtils = {
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 { IServerConfig } from '../../../../../typings/config';
export const phoneState = {
visibility: atom<boolean>({
visibility: atom({
key: 'phoneVisibility',
default: false,
}),
phoneConfig: atom<IServerConfig>({
phoneConfig: atom({
key: 'phoneConfig',
default: null,
default: undefined,
}),
phoneReady: atom<boolean>({
phoneReady: atom({
key: 'phoneReady',
default: false,
}),
phoneTime: atom<string>({
phoneTime: atom({
key: 'phoneTime',
default: null,
}),
+4 -5
View File
@@ -1,15 +1,14 @@
import { useSetRecoilState } from 'recoil';
import { phoneState } from './state';
import { useNuiEvent } from '../../nui-events/hooks/useNuiEvent';
import { PhoneEvents } from '../../../../../typings/phone';
export const usePhoneService = () => {
const setVisibility = useSetRecoilState(phoneState.visibility);
const setPhoneConfig = useSetRecoilState(phoneState.phoneConfig);
const setPhoneReady = useSetRecoilState(phoneState.phoneReady);
const setPhoneTime = useSetRecoilState(phoneState.phoneTime);
useNuiEvent('PHONE', PhoneEvents.SET_VISIBILITY, setVisibility);
useNuiEvent('PHONE', PhoneEvents.SET_PHONE_READY, setPhoneReady);
useNuiEvent('PHONE', PhoneEvents.SET_CONFIG, setPhoneConfig);
useNuiEvent('PHONE', PhoneEvents.SET_TIME, setPhoneTime);
useNuiEvent('PHONE', 'setVisibility', setVisibility);
useNuiEvent('PHONE', 'setPhoneReady', setPhoneReady);
useNuiEvent('PHONE', 'phoneConfig', setPhoneConfig);
useNuiEvent('PHONE', 'setTime', setPhoneTime);
};
@@ -3,7 +3,6 @@ import { useSetRecoilState } from 'recoil';
import { simcardState } from './state';
import { useSimcard } from './useSimcard';
import InjectDebugData from '../../debug/InjectDebugData';
import { PhoneEvents } from '../../../../../typings/phone';
InjectDebugData([
{
@@ -15,6 +14,6 @@ InjectDebugData([
export const useSimcardService = () => {
const setNumber = useSetRecoilState(simcardState.number);
useNuiEvent('SIMCARD', PhoneEvents.SET_NUMBER, setNumber);
useNuiEvent('SIMCARD', 'setNumber', setNumber);
return useSimcard();
};
+7 -4
View File
@@ -2,11 +2,13 @@ import React from 'react';
import Paper from '@material-ui/core/Paper';
import Snackbar from '@material-ui/core/Snackbar';
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 { 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({
paper: {
@@ -23,14 +25,15 @@ function Notification({ children, handleClose, open }) {
const classes = useStyles();
const { config } = usePhone();
const currentTheme = usePhoneTheme();
const [settings] = useRecoilState(settingsState);
if (!config) return null;
const { horizontal, vertical } = config.notificationPosition;
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme.value]);
return (
<ThemeProvider theme={currentTheme}>
<ThemeProvider theme={currentTheme()}>
<Snackbar
className={classes.snackBar}
anchorOrigin={{ horizontal, vertical }}
+19 -22
View File
@@ -1,5 +1,5 @@
import { CallEvents } from '../../typings/call';
import { CallHistoryItem } from '../../typings/call';
import { ICall } from '../../typings/call';
import { phoneCallStartAnim, phoneCallEndAnim } from './functions';
const exp = (global as any).exports;
@@ -34,26 +34,23 @@ on(`__cfx_nui:${CallEvents.ACCEPT_CALL}`, (data: any, cb: Function) => {
cb();
});
onNet(
CallEvents.WAS_ACCEPTED,
(channelId: number, currentCall: CallHistoryItem, isTransmitter: boolean) => {
exp['mumble-voip'].SetCallChannel(channelId);
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
active: true,
transmitter: currentCall.transmitter,
receiver: currentCall.receiver,
isTransmitter: isTransmitter,
accepted: true,
},
}),
);
},
);
onNet(CallEvents.WAS_ACCEPTED, (channelId: number, currentCall: ICall, isTransmitter: boolean) => {
exp['mumble-voip'].SetCallChannel(channelId);
phoneCallStartAnim(); // Trigger call animation only if the call was accepted.
SendNuiMessage(
JSON.stringify({
app: 'CALL',
method: CallEvents.SET_CALLER,
data: {
active: true,
transmitter: currentCall.transmitter,
receiver: currentCall.receiver,
isTransmitter: isTransmitter,
accepted: true,
},
}),
);
});
RegisterNuiCallbackType(CallEvents.REJECTED); // Fires when cancelling and rejecting a call.
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(
JSON.stringify({
app: 'DIALER',
+8 -8
View File
@@ -25,8 +25,8 @@ function fetchOnInitialize() {
emitNet(ContactEvents.GET_CONTACTS);
emitNet(MessageEvents.FETCH_MESSAGE_GROUPS);
emitNet(TwitterEvents.GET_OR_CREATE_PROFILE);
sendMessage('PHONE', PhoneEvents.SET_PHONE_READY, isPhoneReady);
sendMessage('PHONE', PhoneEvents.SET_CONFIG, config);
sendMessage('PHONE', 'setPhoneReady', isPhoneReady);
sendMessage('PHONE', 'phoneConfig', config);
}
RegisterKeyMapping('phone', 'Open Phone', 'keyboard', 'f1');
@@ -55,14 +55,14 @@ const showPhone = async (): Promise<void> => {
await phoneOpenAnim(); // Animation starts before the phone is open
emitNet('phone:getCredentials');
SetCursorLocation(0.9, 0.922); //Experimental
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
sendMessage('PHONE', PhoneEvents.SET_TIME, time);
sendMessage('PHONE', 'setVisibility', true);
sendMessage('PHONE', 'setTime', time);
SetNuiFocus(true, true);
};
const hidePhone = async (): Promise<void> => {
isPhoneOpen = false;
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
sendMessage('PHONE', 'setVisibility', false);
await phoneCloseAnim();
SetNuiFocus(false, false);
};
@@ -115,15 +115,15 @@ onNet(PhoneEvents.PLAYER_IS_READY, fetchOnInitialize);
AddEventHandler('onResourceStop', function (resource: string) {
if (resource === GetCurrentResourceName()) {
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
sendMessage('PHONE', 'setVisibility', false);
SetNuiFocus(false, false);
removePhoneProp(); //Deletes the phone incase it was attached.
ClearPedTasks(PlayerPedId()); //Leave here until launch as it'll fix any stuck animations.
}
});
onNet(PhoneEvents.SEND_CREDENTIALS, (number: string) => {
sendMessage('SIMCARD', PhoneEvents.SET_NUMBER, number);
onNet('phone:sendCredentials', (number: string) => {
sendMessage('SIMCARD', 'setNumber', number);
});
// DO NOT CHANGE THIS EITHER, PLEASE - CHIP
+2 -3
View File
@@ -1,7 +1,6 @@
import { PhotoEvents } from '../../typings/photo';
import { Delay } from '../utils/fivem';
import { sendMessage, sendCameraEvent } from '../utils/messages';
import { PhoneEvents } from '../../typings/phone';
const SCREENSHOT_BASIC_TOKEN = GetConvar('SCREENSHOT_BASIC_TOKEN', 'none');
const exp = (global as any).exports;
@@ -10,12 +9,12 @@ let inCameraMode = false;
function closePhoneTemp() {
SetNuiFocus(false, false);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, false);
sendMessage('PHONE', 'setVisibility', false);
}
function openPhoneTemp() {
SetNuiFocus(true, true);
sendMessage('PHONE', PhoneEvents.SET_VISIBILITY, true);
sendMessage('PHONE', 'setVisibility', true);
}
function CellFrontCamActivate(activate: boolean) {
+6 -6
View File
@@ -1,7 +1,7 @@
import { CallEvents } from '../../typings/call';
import { getIdentifierByPhoneNumber, getPlayer, getSource } from './functions';
import { getPlayerFromIdentifier } from './functions';
import { CallHistoryItem } from '../../typings/call';
import { ICall } from '../../typings/call';
import { pool } from './db';
import { v4 as uuidv4 } from 'uuid';
@@ -9,25 +9,25 @@ import { mainLogger } from './sv_logger';
const callLogger = mainLogger.child({ module: 'calls' });
async function saveCall(call: CallHistoryItem) {
async function saveCall(call: ICall) {
const query =
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
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 = ?';
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 [result] = await pool.query(query, [phoneNumber, phoneNumber]);
const calls = <CallHistoryItem[]>result;
const calls = <ICall[]>result;
return calls;
}
let calls: Map<string, CallHistoryItem> = new Map();
let calls: Map<string, ICall> = new Map();
onNet(CallEvents.INITIALIZE_CALL, async (phoneNumber: string) => {
const _source = getSource();
+1 -2
View File
@@ -1,7 +1,6 @@
import { pool } from './db';
import { getIdentifier, getSource } from './functions';
import { mainLogger } from './sv_logger';
import { PhoneEvents } from '../../typings/phone';
interface Credentials {
phone_number: string;
@@ -20,7 +19,7 @@ onNet('phone:getCredentials', async () => {
try {
const identifier = getIdentifier(_source);
const number = await getCredentials(identifier);
emitNet(PhoneEvents.SEND_CREDENTIALS, _source, number);
emitNet('phone:sendCredentials', _source, number);
} catch (e) {
mainLogger.error(`Failed to get a number, ${e.message}`, {
source: _source,
+9 -2
View File
@@ -1,4 +1,4 @@
export interface ActiveCall {
export interface CallProps {
active: boolean;
accepted: boolean;
isTransmitter: boolean;
@@ -6,7 +6,7 @@ export interface ActiveCall {
receiver: string;
}
export interface CallHistoryItem {
export interface ICall {
id?: number;
identifier: string;
transmitter: string;
@@ -18,6 +18,13 @@ export interface CallHistoryItem {
accepted: boolean;
}
export interface ICallDuration {
ms: number;
s: number;
m: number;
h: number;
}
export enum CallEvents {
INITIALIZE_CALL = 'npwd:beginCall',
START_CALL = 'npwd:startCall',
-6
View File
@@ -11,11 +11,5 @@ export enum PhoneEvents {
OPEN_PHONE = 'npwd:open',
CLOSE_PHONE = 'npwd:close',
SET_ALERT = 'npwd:setAlert',
SET_VISIBILITY = 'npwd:setVisibility',
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',
}