mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
120 in printWidth since rocky got md
This commit is contained in:
1 parent
f552c1212c
commit
d27aeb3b0e
90 files changed
+398
-1146
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"printWidth": 90,
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
|
||||
+1
-4
@@ -8,8 +8,5 @@
|
||||
],
|
||||
"@babel/preset-react"
|
||||
],
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-syntax-dynamic-import"
|
||||
]
|
||||
"plugins": ["@babel/plugin-proposal-class-properties", "@babel/plugin-syntax-dynamic-import"]
|
||||
}
|
||||
@@ -2,14 +2,8 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
/>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Project Error - New Phone Who Dis</title>
|
||||
</head>
|
||||
|
||||
@@ -19,9 +19,7 @@ export const AccountTransactions = (): any => {
|
||||
<div id="account-section">
|
||||
<div className={classes.header}>
|
||||
<h2 className={classes.title}>{t('APPS_BANK_ACCOUNT_TRANSACTIONS')}</h2>
|
||||
<Button className={classes.seeAll}>
|
||||
{t('APPS_BANK_ACCOUNT_SEE_TRANSACTION')}
|
||||
</Button>
|
||||
<Button className={classes.seeAll}>{t('APPS_BANK_ACCOUNT_SEE_TRANSACTION')}</Button>
|
||||
</div>
|
||||
|
||||
<div className={classes.transcationDiv}>
|
||||
|
||||
@@ -25,11 +25,7 @@ export const BankAccount = () => {
|
||||
<div>
|
||||
<h1 className={classes.title}>{t('APPS_BANK_ACCOUNT_TITLE')}</h1>
|
||||
</div>
|
||||
<BankCard
|
||||
name={credentials.name}
|
||||
account="Checking"
|
||||
balance={credentials.balance}
|
||||
/>
|
||||
<BankCard name={credentials.name} account="Checking" balance={credentials.balance} />
|
||||
<AccountTransactions />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -24,8 +24,7 @@ export const BankHome = () => {
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Typography className={classes.headTitle}>
|
||||
<span style={{ fontWeight: 'bold' }}>{t('APPS_BANK_HOME_TITLE')}</span>,{' '}
|
||||
{credentials.name}
|
||||
<span style={{ fontWeight: 'bold' }}>{t('APPS_BANK_HOME_TITLE')}</span>, {credentials.name}
|
||||
</Typography>
|
||||
<div className={classes.accounts}>
|
||||
<h2 className={classes.accountsType}>Checking:</h2>
|
||||
|
||||
@@ -30,21 +30,9 @@ export const NavigationBar = () => {
|
||||
showLabels
|
||||
className={classes.root}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faHome} />}
|
||||
to="/bank"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faMoneyCheck} />}
|
||||
to="/bank/account"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faList} />}
|
||||
to="/bank/transactions"
|
||||
/>
|
||||
<BottomNavigationAction component={Link} icon={<FontAwesomeIcon icon={faHome} />} to="/bank" />
|
||||
<BottomNavigationAction component={Link} icon={<FontAwesomeIcon icon={faMoneyCheck} />} to="/bank/account" />
|
||||
<BottomNavigationAction component={Link} icon={<FontAwesomeIcon icon={faList} />} to="/bank/transactions" />
|
||||
</BottomNavigation>
|
||||
);
|
||||
};
|
||||
@@ -33,22 +33,20 @@ export const TransactionList = () => {
|
||||
</div>
|
||||
|
||||
<div className={classes.transcationDiv}>
|
||||
{transactionList
|
||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||
.map((transaction: any) => (
|
||||
<div className={classes.transactions}>
|
||||
<div>
|
||||
<h1 className={classes.tranSource}>{transaction.source}</h1>
|
||||
<p className={classes.tranType}>{transaction.type}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className={TransactionTypes[transaction.type]}>
|
||||
{transaction.type === 'Withdraw' ? '-' : '+'}
|
||||
{transaction.amount}
|
||||
</p>
|
||||
</div>
|
||||
{transactionList.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((transaction: any) => (
|
||||
<div className={classes.transactions}>
|
||||
<div>
|
||||
<h1 className={classes.tranSource}>{transaction.source}</h1>
|
||||
<p className={classes.tranType}>{transaction.type}</p>
|
||||
</div>
|
||||
))}
|
||||
<div>
|
||||
<p className={TransactionTypes[transaction.type]}>
|
||||
{transaction.type === 'Withdraw' ? '-' : '+'}
|
||||
{transaction.amount}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<TablePagination
|
||||
rowsPerPageOptions={[3, 5]}
|
||||
className={classes.pagination}
|
||||
|
||||
@@ -28,18 +28,9 @@ export const GalleryGrid = () => {
|
||||
|
||||
if (!photos)
|
||||
return (
|
||||
<Box
|
||||
display="flex"
|
||||
flexWrap="wrap"
|
||||
alignContent="flex-start"
|
||||
className={classes.root}
|
||||
>
|
||||
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
|
||||
<Box>
|
||||
<Button
|
||||
onClick={handleCamera}
|
||||
style={{ borderRadius: 0 }}
|
||||
className={classes.photo}
|
||||
>
|
||||
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
|
||||
<AddIcon fontSize="large" />
|
||||
</Button>
|
||||
</Box>
|
||||
@@ -48,27 +39,15 @@ export const GalleryGrid = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Box
|
||||
display="flex"
|
||||
flexWrap="wrap"
|
||||
alignContent="flex-start"
|
||||
className={classes.root}
|
||||
>
|
||||
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
|
||||
<Box>
|
||||
<Button
|
||||
onClick={handleCamera}
|
||||
style={{ borderRadius: 0 }}
|
||||
className={classes.photo}
|
||||
>
|
||||
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
|
||||
<AddIcon fontSize="large" />
|
||||
</Button>
|
||||
</Box>
|
||||
{photos.map((photo) => (
|
||||
<Box key={photo.id} onClick={() => handlePhotoOpen(photo)}>
|
||||
<div
|
||||
style={{ backgroundImage: `url(${photo.image})` }}
|
||||
className={classes.photo}
|
||||
/>
|
||||
<div style={{ backgroundImage: `url(${photo.image})` }} className={classes.photo} />
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
|
||||
@@ -18,10 +18,7 @@ export const GalleryModal = () => {
|
||||
|
||||
const [shareOpen, setShareOpen] = useState(null);
|
||||
|
||||
const meta: ICameraPhoto = useMemo(
|
||||
() => ({ id: query.id as string, 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);
|
||||
@@ -48,10 +45,7 @@ export const GalleryModal = () => {
|
||||
<Button onClick={_handleClose}>
|
||||
<ArrowBackIcon />
|
||||
</Button>
|
||||
<div
|
||||
className={classes.image}
|
||||
style={{ backgroundImage: `url(${meta.image})` }}
|
||||
/>
|
||||
<div className={classes.image} style={{ backgroundImage: `url(${meta.image})` }} />
|
||||
<div className={classes.actionDiv}>
|
||||
<Button onClick={handleDeletePhoto}>
|
||||
<DeleteIcon fontSize="large" />
|
||||
|
||||
@@ -28,9 +28,7 @@ export const ShareModal = ({ meta, onClose, referal }: IShareModalProps) => {
|
||||
<div className={classes.shareModal}>
|
||||
<div className={classes.innerShareModal}>
|
||||
<>
|
||||
<h4 style={{ textAlign: 'center', marginTop: 20 }}>
|
||||
Where do you want to share the photo?
|
||||
</h4>
|
||||
<h4 style={{ textAlign: 'center', marginTop: 20 }}>Where do you want to share the photo?</h4>
|
||||
<Button>{<MessageIcon />} Message</Button>
|
||||
<h4>Or just copy the image here:</h4>
|
||||
<Button onClick={handleCopyImage} variant="contained">
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import React from 'react';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import {
|
||||
Button,
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar,
|
||||
List,
|
||||
ListItem,
|
||||
} from '@material-ui/core';
|
||||
import { Button, ListItemAvatar, Avatar as MuiAvatar, List, ListItem } from '@material-ui/core';
|
||||
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import ChatIcon from '@material-ui/icons/Chat';
|
||||
@@ -54,10 +48,7 @@ export const ContactList = () => {
|
||||
<SearchContacts />
|
||||
<List>
|
||||
{contacts
|
||||
.filter(
|
||||
(contact) =>
|
||||
contact.display.match(filteredRegEx) || contact.number.match(filteredRegEx),
|
||||
)
|
||||
.filter((contact) => contact.display.match(filteredRegEx) || contact.number.match(filteredRegEx))
|
||||
.map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
|
||||
@@ -25,11 +25,7 @@ export const ContactPage = () => {
|
||||
return (
|
||||
<>
|
||||
<ContactList />
|
||||
<Fab
|
||||
color="primary"
|
||||
onClick={() => history.push('/contacts/-1')}
|
||||
className={classes.absolute}
|
||||
>
|
||||
<Fab color="primary" onClick={() => history.push('/contacts/-1')} className={classes.absolute}>
|
||||
<PersonAddIcon />
|
||||
</Fab>
|
||||
</>
|
||||
|
||||
@@ -7,8 +7,6 @@ interface FilterdContactsProps {
|
||||
}
|
||||
|
||||
export const useFilteredContacts = (): FilterdContactsProps => {
|
||||
const [filteredContacts, setFilteredContacts] = useRecoilState(
|
||||
contactsState.filterContacts,
|
||||
);
|
||||
const [filteredContacts, setFilteredContacts] = useRecoilState(contactsState.filterContacts);
|
||||
return { filteredContacts, setFilteredContacts };
|
||||
};
|
||||
@@ -44,11 +44,7 @@ export const DialerInput = () => {
|
||||
|
||||
return (
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase
|
||||
placeholder="Enter a number"
|
||||
className={classes.input}
|
||||
value={inputVal}
|
||||
/>
|
||||
<InputBase placeholder="Enter a number" className={classes.input} value={inputVal} />
|
||||
<IconButton color="primary" className={classes.iconBtn}>
|
||||
<PhoneIcon fontSize="large" onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
|
||||
@@ -26,19 +26,8 @@ const DialerNavBar = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<BottomNavigation
|
||||
value={page}
|
||||
onChange={handleChange}
|
||||
showLabels
|
||||
className={classes.root}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
label="History"
|
||||
value="/phone"
|
||||
component={NavLink}
|
||||
icon={<HistoryIcon />}
|
||||
to="/phone"
|
||||
/>
|
||||
<BottomNavigation value={page} onChange={handleChange} showLabels className={classes.root}>
|
||||
<BottomNavigationAction label="History" value="/phone" component={NavLink} icon={<HistoryIcon />} to="/phone" />
|
||||
<BottomNavigationAction
|
||||
label="Dial"
|
||||
value="/phone/dial"
|
||||
|
||||
@@ -58,25 +58,17 @@ export const DialerHistory = ({ calls }) => {
|
||||
{calls.map((call: ICall) =>
|
||||
call.transmitter === number ? (
|
||||
<ListItem key={call.id} divider>
|
||||
<ListItemIcon>
|
||||
{<PhoneForwardedIcon className={classes.callForward} />}
|
||||
</ListItemIcon>
|
||||
<ListItemIcon>{<PhoneForwardedIcon className={classes.callForward} />}</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.receiver)}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
/>
|
||||
<IconButton onClick={() => handleCall(call.receiver)}>
|
||||
{<PhoneIcon />}
|
||||
</IconButton>
|
||||
<IconButton onClick={() => handleCall(call.receiver)}>{<PhoneIcon />}</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(
|
||||
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`,
|
||||
)
|
||||
}
|
||||
onClick={() => history.push(`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`)}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
</IconButton>
|
||||
@@ -84,25 +76,17 @@ export const DialerHistory = ({ calls }) => {
|
||||
</ListItem>
|
||||
) : (
|
||||
<ListItem key={call.id} divider>
|
||||
<ListItemIcon>
|
||||
{<PhoneCallbackIcon className={classes.callBack} />}
|
||||
</ListItemIcon>
|
||||
<ListItemIcon>{<PhoneCallbackIcon className={classes.callBack} />}</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.transmitter)}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
/>
|
||||
<IconButton onClick={() => handleCall(call.transmitter)}>
|
||||
{<PhoneIcon />}
|
||||
</IconButton>
|
||||
<IconButton onClick={() => handleCall(call.transmitter)}>{<PhoneIcon />}</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(
|
||||
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`,
|
||||
)
|
||||
}
|
||||
onClick={() => history.push(`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`)}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
</IconButton>
|
||||
|
||||
@@ -35,9 +35,7 @@ export const ExampleApp = () => {
|
||||
<Button color="primary">{example.id}</Button>
|
||||
{/* Here we are using the value in a h3 tag */}
|
||||
<h3>{exampleString}</h3>
|
||||
<IconButton onClick={() => (playing ? stop() : play())}>
|
||||
{playing ? <StopIcon /> : <PlayIcon />}
|
||||
</IconButton>
|
||||
<IconButton onClick={() => (playing ? stop() : play())}>{playing ? <StopIcon /> : <PlayIcon />}</IconButton>
|
||||
<Button onClick={toggleSound}>Change sound on the fly</Button>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
|
||||
@@ -38,11 +38,7 @@ export const MessagesApp = () => {
|
||||
/>
|
||||
</Switch>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path={['/messages/new/:phoneNumber', '/messages/new']}
|
||||
render={() => <MessageGroupModal />}
|
||||
/>
|
||||
<Route exact path={['/messages/new/:phoneNumber', '/messages/new']} render={() => <MessageGroupModal />} />
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<NewMessageGroupButton onClick={() => history.push('/messages/new')} />
|
||||
|
||||
@@ -32,9 +32,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
// handles phone numbers in a csv format and strips all spaces and
|
||||
// external characters out of them:
|
||||
// 123-4567, 987-6543, 333-4444
|
||||
const phoneNumbers = participants.map(({ number }) =>
|
||||
number.replace(/[^0-9]/g, ''),
|
||||
);
|
||||
const phoneNumbers = participants.map(({ number }) => number.replace(/[^0-9]/g, ''));
|
||||
const labelValue = isGroupChat ? label.trim() : null;
|
||||
|
||||
if (phoneNumbers.length) {
|
||||
@@ -101,13 +99,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
</Box>
|
||||
)}
|
||||
<Box px={2} py={3}>
|
||||
<Button
|
||||
disabled={submitDisabled}
|
||||
variant="contained"
|
||||
fullWidth
|
||||
color="primary"
|
||||
type="submit"
|
||||
>
|
||||
<Button disabled={submitDisabled} variant="contained" fullWidth color="primary" type="submit">
|
||||
{t('APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT')}
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
ListItem,
|
||||
ListItemText,
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar,
|
||||
} from '@material-ui/core';
|
||||
import { ListItem, ListItemText, ListItemAvatar, Avatar as MuiAvatar } from '@material-ui/core';
|
||||
|
||||
import { MessageGroup } from '../../../../common/typings/messages';
|
||||
|
||||
@@ -15,12 +10,7 @@ interface IProps {
|
||||
|
||||
const MessageGroupItem = ({ messageGroup, handleClick }: IProps): any => {
|
||||
return (
|
||||
<ListItem
|
||||
key={messageGroup.groupId}
|
||||
onClick={handleClick(messageGroup)}
|
||||
divider
|
||||
button
|
||||
>
|
||||
<ListItem key={messageGroup.groupId} onClick={handleClick(messageGroup)} divider button>
|
||||
<ListItemAvatar>
|
||||
<MuiAvatar src={messageGroup?.avatar} />
|
||||
</ListItemAvatar>
|
||||
|
||||
@@ -7,9 +7,7 @@ import useStyles from './list.styles';
|
||||
|
||||
interface IProps {
|
||||
value: string;
|
||||
handleChange: (
|
||||
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
|
||||
) => void;
|
||||
handleChange: (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
const MessageSearch = ({ value, handleChange }: IProps) => {
|
||||
|
||||
@@ -13,46 +13,30 @@ const MessagesList = (): any => {
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
|
||||
const {
|
||||
messageGroups,
|
||||
createMessageGroupResult,
|
||||
clearMessageGroupResult,
|
||||
} = useMessages();
|
||||
const { messageGroups, createMessageGroupResult, clearMessageGroupResult } = useMessages();
|
||||
|
||||
const [searchValue, setSearchValue] = useState('');
|
||||
|
||||
const goToConversation = useCallback(
|
||||
(messageGroup) =>
|
||||
history.push(
|
||||
`/messages/conversations/${messageGroup.groupId}/?${qs.stringify(messageGroup)}`,
|
||||
),
|
||||
(messageGroup) => history.push(`/messages/conversations/${messageGroup.groupId}/?${qs.stringify(messageGroup)}`),
|
||||
[history],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (createMessageGroupResult?.groupId) {
|
||||
const findGroup = messageGroups.find(
|
||||
(g) => g.groupId === createMessageGroupResult.groupId,
|
||||
);
|
||||
const findGroup = messageGroups.find((g) => g.groupId === createMessageGroupResult.groupId);
|
||||
clearMessageGroupResult();
|
||||
if (findGroup) {
|
||||
goToConversation(findGroup);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
messageGroups,
|
||||
createMessageGroupResult,
|
||||
goToConversation,
|
||||
clearMessageGroupResult,
|
||||
]);
|
||||
}, [messageGroups, createMessageGroupResult, goToConversation, clearMessageGroupResult]);
|
||||
|
||||
if (!messageGroups) return null;
|
||||
|
||||
const handleClick = (messageGroup: MessageGroup) => () => {
|
||||
Nui.send('phone:fetchMessages', { groupId: messageGroup.groupId });
|
||||
history.push(
|
||||
`/messages/conversations/${messageGroup.groupId}/?${qs.stringify(messageGroup)}`,
|
||||
);
|
||||
history.push(`/messages/conversations/${messageGroup.groupId}/?${qs.stringify(messageGroup)}`);
|
||||
};
|
||||
|
||||
const formattedSearch = searchValue.toLowerCase().trim();
|
||||
@@ -62,25 +46,16 @@ const MessagesList = (): any => {
|
||||
const displayIncludes = groupDisplay.includes(formattedSearch);
|
||||
|
||||
const label = group.label?.toLowerCase();
|
||||
return label
|
||||
? displayIncludes || label.includes(formattedSearch)
|
||||
: displayIncludes;
|
||||
return label ? displayIncludes || label.includes(formattedSearch) : displayIncludes;
|
||||
})
|
||||
: messageGroups;
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageSearch
|
||||
value={searchValue}
|
||||
handleChange={(e) => setSearchValue(e.target.value)}
|
||||
/>
|
||||
<MessageSearch value={searchValue} handleChange={(e) => setSearchValue(e.target.value)} />
|
||||
<List className={classes.root}>
|
||||
{filteredGroups.map((messageGroup) => (
|
||||
<MessageGroupItem
|
||||
key={messageGroup.groupId}
|
||||
messageGroup={messageGroup}
|
||||
handleClick={handleClick}
|
||||
/>
|
||||
<MessageGroupItem key={messageGroup.groupId} messageGroup={messageGroup} handleClick={handleClick} />
|
||||
))}
|
||||
</List>
|
||||
</>
|
||||
|
||||
@@ -38,17 +38,10 @@ const Conversation = ({ activeMessageGroup, messages }: IProps) => {
|
||||
className={classes.overflowAutoY}
|
||||
>
|
||||
{messages.map((message) => (
|
||||
<MessageBubble
|
||||
key={message.id}
|
||||
message={message}
|
||||
isGroupChat={activeMessageGroup?.isGroupChat}
|
||||
/>
|
||||
<MessageBubble key={message.id} message={message} isGroupChat={activeMessageGroup?.isGroupChat} />
|
||||
))}
|
||||
</Box>
|
||||
<MessageInput
|
||||
messageGroupId={activeMessageGroup.groupId}
|
||||
onAddImageClick={() => setImageModalOpen(true)}
|
||||
/>
|
||||
<MessageInput messageGroupId={activeMessageGroup.groupId} onAddImageClick={() => setImageModalOpen(true)} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -41,33 +41,21 @@ const isImage = (url) => {
|
||||
return /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|png|jpeg|gif)/g.test(url);
|
||||
};
|
||||
|
||||
export const MessageBubble = ({
|
||||
message,
|
||||
isGroupChat,
|
||||
}: {
|
||||
message: Message;
|
||||
isGroupChat: boolean;
|
||||
}) => {
|
||||
export const MessageBubble = ({ message, isGroupChat }: { message: Message; isGroupChat: boolean }) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div>
|
||||
<Paper className={message.isMine ? classes.mySms : classes.sms} variant="outlined">
|
||||
<Box>
|
||||
{isImage(message.message) ? (
|
||||
<img
|
||||
src={message.message}
|
||||
className={classes.imageMessage}
|
||||
alt="multimedia"
|
||||
/>
|
||||
<img src={message.message} className={classes.imageMessage} alt="multimedia" />
|
||||
) : (
|
||||
<div>{message.message}</div>
|
||||
)}
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography variant="subtitle1" color="secondary">
|
||||
{isGroupChat && !message.isMine
|
||||
? message.display || message.phone_number
|
||||
: null}
|
||||
{isGroupChat && !message.isMine ? message.display || message.phone_number : null}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Paper>
|
||||
|
||||
@@ -89,10 +89,7 @@ export const MessageImageModal = ({ isOpen, messageGroupId, onClose, image }: IP
|
||||
<Modal visible={queryParamImagePreview} handleClose={removeQueryParamImage}>
|
||||
<Box py={1}>
|
||||
<Typography paragraph>Do you want to share this image?</Typography>
|
||||
<PictureResponsive
|
||||
src={queryParamImagePreview}
|
||||
alt={'Share gallery image preview'}
|
||||
/>
|
||||
<PictureResponsive src={queryParamImagePreview} alt={'Share gallery image preview'} />
|
||||
<Button
|
||||
fullWidth
|
||||
variant="contained"
|
||||
|
||||
@@ -75,13 +75,9 @@ export const MessageModal = () => {
|
||||
// don't allow too many characters, it takes too much room
|
||||
let header = activeMessageGroup ? activeMessageGroup.groupDisplay : '';
|
||||
const truncatedHeader = `${header.slice(0, MAX_HEADER_CHARS).trim()}...`;
|
||||
header =
|
||||
header.length > MAX_HEADER_CHARS
|
||||
? activeMessageGroup?.label || truncatedHeader
|
||||
: header;
|
||||
header = header.length > MAX_HEADER_CHARS ? activeMessageGroup?.label || truncatedHeader : header;
|
||||
|
||||
const headerClass =
|
||||
header.length > LARGE_HEADER_CHARS ? classes.largeGroupDisplay : classes.groupdisplay;
|
||||
const headerClass = header.length > LARGE_HEADER_CHARS ? classes.largeGroupDisplay : classes.groupdisplay;
|
||||
|
||||
return (
|
||||
<Slide direction="left" in={!!activeMessageGroup}>
|
||||
|
||||
@@ -6,9 +6,7 @@ import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
export const useMessagesService = () => {
|
||||
const setMessageGroups = useSetRecoilState(messageState.messageGroups);
|
||||
const setMessages = useSetRecoilState(messageState.messages);
|
||||
const setCreateMessageGroupResult = useSetRecoilState(
|
||||
messageState.createMessageGroupResult,
|
||||
);
|
||||
const setCreateMessageGroupResult = useSetRecoilState(messageState.createMessageGroupResult);
|
||||
const { addAlert } = useSnackbar();
|
||||
|
||||
useNuiEvent('MESSAGES', 'phone:fetchMessageGroupsSuccess', setMessageGroups);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
import {
|
||||
CreateMessageGroupResult,
|
||||
Message,
|
||||
MessageGroup,
|
||||
} from '../../../common/typings/messages';
|
||||
import { CreateMessageGroupResult, Message, MessageGroup } from '../../../common/typings/messages';
|
||||
import { messageState } from './state';
|
||||
|
||||
interface IUseMessages {
|
||||
@@ -18,10 +14,7 @@ export default (): IUseMessages => {
|
||||
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
|
||||
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
|
||||
|
||||
const [
|
||||
createMessageGroupResult,
|
||||
setCreateMessageGroupResult,
|
||||
] = useRecoilState<CreateMessageGroupResult | null>(
|
||||
const [createMessageGroupResult, setCreateMessageGroupResult] = useRecoilState<CreateMessageGroupResult | null>(
|
||||
messageState.createMessageGroupResult,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
import {
|
||||
Button,
|
||||
TextField,
|
||||
Slide,
|
||||
Paper,
|
||||
Typography,
|
||||
Container,
|
||||
CircularProgress,
|
||||
Box,
|
||||
} from '@material-ui/core';
|
||||
import { Button, TextField, Slide, Paper, Typography, Container, CircularProgress, Box } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
@@ -109,11 +100,7 @@ export const NoteModal = () => {
|
||||
</Button>
|
||||
</Box>
|
||||
<Box display="inline" p={1}>
|
||||
<StatusButton
|
||||
color="error"
|
||||
variant="contained"
|
||||
onClick={_handleClose}
|
||||
>
|
||||
<StatusButton color="error" variant="contained" onClick={_handleClose}>
|
||||
{t('GENERIC_CANCEL')}
|
||||
</StatusButton>
|
||||
</Box>
|
||||
@@ -121,20 +108,12 @@ export const NoteModal = () => {
|
||||
) : (
|
||||
<>
|
||||
<Box display="inline" p={1}>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
<Button color="primary" variant="contained" onClick={handleUpdateNote}>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
</Box>
|
||||
<Box display="inline" p={1}>
|
||||
<StatusButton
|
||||
color="error"
|
||||
variant="contained"
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
<StatusButton color="error" variant="contained" onClick={handleDeleteNote}>
|
||||
{t('GENERIC_DELETE')}
|
||||
</StatusButton>
|
||||
</Box>
|
||||
|
||||
@@ -54,10 +54,7 @@ export const SelloutItem = (listing) => {
|
||||
<Typography className={classes.headerTypo} variant="h5">
|
||||
{listing.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
className={classes.headerTypo}
|
||||
style={{ borderBottom: '1px solid #f44336' }}
|
||||
>
|
||||
<Typography className={classes.headerTypo} style={{ borderBottom: '1px solid #f44336' }}>
|
||||
{listing.number}
|
||||
</Typography>
|
||||
<Typography variant="h5" style={{ padding: 5 }}>
|
||||
|
||||
@@ -28,16 +28,8 @@ export const NavigationBar = () => {
|
||||
showLabels
|
||||
className={classes.root}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<FontAwesomeIcon icon={faHome} />}
|
||||
to="/sellout"
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
icon={<AddCircleIcon />}
|
||||
to="/sellout/new"
|
||||
/>
|
||||
<BottomNavigationAction component={Link} icon={<FontAwesomeIcon icon={faHome} />} to="/sellout" />
|
||||
<BottomNavigationAction component={Link} icon={<AddCircleIcon />} to="/sellout/new" />
|
||||
</BottomNavigation>
|
||||
);
|
||||
};
|
||||
@@ -10,15 +10,7 @@ import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { SettingItem } from './SettingItem';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import {
|
||||
Brush,
|
||||
Wallpaper,
|
||||
Phone,
|
||||
Smartphone,
|
||||
ZoomIn,
|
||||
LibraryMusic,
|
||||
VolumeUp,
|
||||
} from '@material-ui/icons';
|
||||
import { Brush, Wallpaper, Phone, Smartphone, ZoomIn, LibraryMusic, VolumeUp } from '@material-ui/icons';
|
||||
|
||||
import {
|
||||
Box,
|
||||
@@ -53,11 +45,7 @@ export const SettingsApp = () => {
|
||||
useEffect(() => {
|
||||
setSliders((curr) => {
|
||||
if (!curr.length) {
|
||||
return [
|
||||
settings.ringtoneVol,
|
||||
settings.notificationVol,
|
||||
settings.TWITTER_notificationVol,
|
||||
];
|
||||
return [settings.ringtoneVol, settings.notificationVol, settings.TWITTER_notificationVol];
|
||||
}
|
||||
return curr;
|
||||
});
|
||||
@@ -74,9 +62,7 @@ export const SettingsApp = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const wallpapers = config.wallpapers.map(
|
||||
MapStringOptions(settings.wallpaper, (val: string) =>
|
||||
handleSettingChange('wallpaper', val),
|
||||
),
|
||||
MapStringOptions(settings.wallpaper, (val: string) => handleSettingChange('wallpaper', val)),
|
||||
);
|
||||
const frames = config.frames.map(
|
||||
MapStringOptions(settings.frame, (val: string) => handleSettingChange('frame', val)),
|
||||
@@ -88,20 +74,14 @@ export const SettingsApp = () => {
|
||||
MapStringOptions(settings.zoom, (val: string) => handleSettingChange('zoom', val)),
|
||||
);
|
||||
const ringtones = config.ringtones.map(
|
||||
MapStringOptions(settings.ringtone, (val: string) =>
|
||||
handleSettingChange('ringtone', val),
|
||||
),
|
||||
MapStringOptions(settings.ringtone, (val: string) => handleSettingChange('ringtone', val)),
|
||||
);
|
||||
const notifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('notification', val),
|
||||
),
|
||||
MapStringOptions(settings.notification, (val: string) => handleSettingChange('notification', val)),
|
||||
);
|
||||
|
||||
const twitterNotifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('TWITTER_notification', val),
|
||||
),
|
||||
MapStringOptions(settings.notification, (val: string) => handleSettingChange('TWITTER_notification', val)),
|
||||
);
|
||||
|
||||
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
||||
@@ -110,11 +90,7 @@ export const SettingsApp = () => {
|
||||
<AppTitle app={settingsApp} />
|
||||
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
||||
<List disablePadding subheader={<SubHeaderComp text="Phone" />}>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
||||
value={simcard.number}
|
||||
icon={<Phone />}
|
||||
/>
|
||||
<SettingItem label={t('APPS_SETTINGS_PHONE_NUMBER')} value={simcard.number} icon={<Phone />} />
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
||||
value={settings.ringtone}
|
||||
@@ -126,10 +102,7 @@ export const SettingsApp = () => {
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
||||
secondary={settings.ringtoneVol}
|
||||
/>
|
||||
<ListItemText primary={t('APPS_SETTINGS_OPTION_RINGTONEVOL')} secondary={settings.ringtoneVol} />
|
||||
<ListItemSecondaryAction>
|
||||
<Box p={2} width={150}>
|
||||
<Slider
|
||||
@@ -153,10 +126,7 @@ export const SettingsApp = () => {
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||
secondary={settings.notificationVol}
|
||||
/>
|
||||
<ListItemText primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')} secondary={settings.notificationVol} />
|
||||
<ListItemSecondaryAction>
|
||||
<Box p={2} width={150}>
|
||||
<Slider
|
||||
@@ -164,9 +134,7 @@ export const SettingsApp = () => {
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={handleSliderChange(1)}
|
||||
onChangeCommitted={() =>
|
||||
handleSettingChange('notificationVol', sliders[1])
|
||||
}
|
||||
onChangeCommitted={() => handleSettingChange('notificationVol', sliders[1])}
|
||||
/>
|
||||
</Box>
|
||||
</ListItemSecondaryAction>
|
||||
@@ -226,9 +194,7 @@ export const SettingsApp = () => {
|
||||
min={0}
|
||||
max={100}
|
||||
onChange={handleSliderChange(2)}
|
||||
onChangeCommitted={() =>
|
||||
handleSettingChange('TWITTER_notificationVol', sliders[2])
|
||||
}
|
||||
onChangeCommitted={() => handleSettingChange('TWITTER_notificationVol', sliders[2])}
|
||||
/>
|
||||
</Box>
|
||||
</ListItemSecondaryAction>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export const getRingtonePath = (name?: string) =>
|
||||
`./media/ringtones/${name || 'pixel'}.ogg`;
|
||||
export const getRingtonePath = (name?: string) => `./media/ringtones/${name || 'pixel'}.ogg`;
|
||||
|
||||
export const getNotificationPath = (name?: string) =>
|
||||
`./media/notifications/${name || 'online'}.ogg`;
|
||||
export const getNotificationPath = (name?: string) => `./media/notifications/${name || 'online'}.ogg`;
|
||||
@@ -106,10 +106,7 @@ export const AddTweetModal = () => {
|
||||
|
||||
const data = {
|
||||
message,
|
||||
images:
|
||||
images && images.length > 0
|
||||
? images.map((image) => image.link).join(IMAGE_DELIMITER)
|
||||
: '',
|
||||
images: images && images.length > 0 ? images.map((image) => image.link).join(IMAGE_DELIMITER) : '',
|
||||
realUser: 'testUser',
|
||||
};
|
||||
Nui.send('phone:createTweet', data);
|
||||
@@ -158,27 +155,13 @@ export const AddTweetModal = () => {
|
||||
|
||||
return (
|
||||
<Modal visible={modalVisible} handleClose={_handleClose}>
|
||||
<TweetMessage
|
||||
modalVisible={modalVisible}
|
||||
message={message}
|
||||
handleChange={handleMessageChange}
|
||||
/>
|
||||
<ImagePrompt
|
||||
visible={showImagePrompt}
|
||||
value={link}
|
||||
handleChange={handleimageChange}
|
||||
/>
|
||||
<TweetMessage modalVisible={modalVisible} message={message} handleChange={handleMessageChange} />
|
||||
<ImagePrompt visible={showImagePrompt} value={link} handleChange={handleimageChange} />
|
||||
<EmojiSelect visible={showEmoji} onEmojiClick={handleSelectEmoji} />
|
||||
<ImageDisplay
|
||||
visible={!showEmoji && images.length > 0}
|
||||
images={images}
|
||||
removeImage={removeImage}
|
||||
/>
|
||||
<ImageDisplay visible={!showEmoji && images.length > 0} images={images} removeImage={removeImage} />
|
||||
<div className={classes.buttonsContainer}>
|
||||
<IconButtons
|
||||
onImageClick={
|
||||
images.length < config.twitter.maxImages ? toggleShowImagePrompt : null
|
||||
}
|
||||
onImageClick={images.length < config.twitter.maxImages ? toggleShowImagePrompt : null}
|
||||
onEmojiClick={toggleShowEmoji}
|
||||
/>
|
||||
<ControlButtons
|
||||
|
||||
@@ -18,16 +18,8 @@ export function TwitterBottomNavigation({ activePage, handleChange }) {
|
||||
return (
|
||||
<BottomNavigation value={activePage} onChange={handleChange} className={classes.root}>
|
||||
<BottomNavigationAction component={Link} to="/twitter" icon={<HomeIcon />} />
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
to="/twitter/search"
|
||||
icon={<SearchIcon />}
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
component={Link}
|
||||
to="/twitter/profile"
|
||||
icon={<ProfileIcon />}
|
||||
/>
|
||||
<BottomNavigationAction component={Link} to="/twitter/search" icon={<SearchIcon />} />
|
||||
<BottomNavigationAction component={Link} to="/twitter/profile" icon={<ProfileIcon />} />
|
||||
</BottomNavigation>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ export const TwitterApp = () => {
|
||||
|
||||
// before any other action can be taken by the user we force
|
||||
// them have a profile name
|
||||
const promptProfileName =
|
||||
profile && (!profile.profile_name || !profile.profile_name.trim());
|
||||
const promptProfileName = profile && (!profile.profile_name || !profile.profile_name.trim());
|
||||
|
||||
const openModal = () => setModalVisible(true);
|
||||
const handlePageChange = (e, page) => setActivePage(page);
|
||||
@@ -83,9 +82,7 @@ export const TwitterApp = () => {
|
||||
)}
|
||||
</AppContent>
|
||||
{showTweetButton && <TweetButton openModal={openModal} />}
|
||||
{!promptProfileName && (
|
||||
<BottomNavigation activePage={activePage} handleChange={handlePageChange} />
|
||||
)}
|
||||
{!promptProfileName && <BottomNavigation activePage={activePage} handleChange={handlePageChange} />}
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,19 +16,12 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export const ControlButtons = ({
|
||||
showImagePrompt,
|
||||
showEmoji,
|
||||
onCloseClick,
|
||||
onPrimaryClick,
|
||||
}) => {
|
||||
export const ControlButtons = ({ showImagePrompt, showEmoji, onCloseClick, onPrimaryClick }) => {
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const imagePromptVisible = showImagePrompt && !showEmoji;
|
||||
const primaryButtonText = imagePromptVisible
|
||||
? t('APPS_TWITTER_SUBMIT_IMAGE')
|
||||
: t('APPS_TWITTER_TWEET');
|
||||
const primaryButtonText = imagePromptVisible ? t('APPS_TWITTER_SUBMIT_IMAGE') : t('APPS_TWITTER_TWEET');
|
||||
const showCloseButton = showImagePrompt || showEmoji;
|
||||
|
||||
return (
|
||||
@@ -37,12 +30,7 @@ export const ControlButtons = ({
|
||||
{primaryButtonText}
|
||||
</Button>
|
||||
{showCloseButton && (
|
||||
<Button
|
||||
className={classes.close}
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
onClick={onCloseClick}
|
||||
>
|
||||
<Button className={classes.close} variant="contained" color="secondary" onClick={onCloseClick}>
|
||||
{t('APPS_TWITTER_CLOSE_IMAGE')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -28,11 +28,7 @@ function LikeButton({ tweetId, isLiked }) {
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick}>
|
||||
{liked ? <FavoriteIcon /> : <FavoriteBorderIcon />}
|
||||
</Button>
|
||||
);
|
||||
return <Button onClick={handleClick}>{liked ? <FavoriteIcon /> : <FavoriteBorderIcon />}</Button>;
|
||||
}
|
||||
|
||||
export default LikeButton;
|
||||
@@ -35,12 +35,7 @@ export function ProfileUpdateButton({ handleClick }) {
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<Fab
|
||||
className={classes.button}
|
||||
color="primary"
|
||||
onClick={handleClick}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Fab className={classes.button} color="primary" onClick={handleClick} disabled={isLoading}>
|
||||
<PublishIcon />
|
||||
</Fab>
|
||||
</div>
|
||||
|
||||
@@ -45,11 +45,7 @@ export const Image = ({ link, handleClick, small }) => {
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
)}
|
||||
<img
|
||||
alt="small avatar"
|
||||
className={small ? classes.imgSmall : classes.img}
|
||||
src={link}
|
||||
/>
|
||||
<img alt="small avatar" className={small ? classes.imgSmall : classes.img} src={link} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -23,9 +23,7 @@ export const ImagePrompt = ({ visible, value, handleChange }) => {
|
||||
textFieldRef.current && textFieldRef.current.focus();
|
||||
}, [visible]);
|
||||
|
||||
const handleImageChange = useCallback((e) => handleChange(e.target.value), [
|
||||
handleChange,
|
||||
]);
|
||||
const handleImageChange = useCallback((e) => handleChange(e.target.value), [handleChange]);
|
||||
|
||||
if (!visible) return null;
|
||||
return (
|
||||
|
||||
@@ -70,22 +70,13 @@ export function Profile() {
|
||||
handleChange={handleNameChange}
|
||||
allowChange={allowEdtiableProfileName}
|
||||
/>
|
||||
<ProfileField
|
||||
label={t('APPS_TWITTER_EDIT_PROFILE_BIO')}
|
||||
value={bio}
|
||||
handleChange={handleBioChange}
|
||||
multiline
|
||||
/>
|
||||
<ProfileField label={t('APPS_TWITTER_EDIT_PROFILE_BIO')} value={bio} handleChange={handleBioChange} multiline />
|
||||
<ProfileField
|
||||
label={t('APPS_TWITTER_EDIT_PROFILE_LOCATION')}
|
||||
value={location}
|
||||
handleChange={handleLocationChange}
|
||||
/>
|
||||
<ProfileField
|
||||
label={t('APPS_TWITTER_EDIT_PROFILE_JOB')}
|
||||
value={job}
|
||||
handleChange={handleJobChange}
|
||||
/>
|
||||
<ProfileField label={t('APPS_TWITTER_EDIT_PROFILE_JOB')} value={job} handleChange={handleJobChange} />
|
||||
<ProfileUpdateButton handleClick={handleUpdate} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -76,12 +76,8 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
horizontal: 'left',
|
||||
}}
|
||||
>
|
||||
{allowedToDelete && (
|
||||
<MenuItem onClick={handleDeleteTweet}>{t('APPS_TWITTER_DELETE')}</MenuItem>
|
||||
)}
|
||||
{allowedToReport && (
|
||||
<ReportButton handleClose={handleClose} isReported={isReported} tweetId={id} />
|
||||
)}
|
||||
{allowedToDelete && <MenuItem onClick={handleDeleteTweet}>{t('APPS_TWITTER_DELETE')}</MenuItem>}
|
||||
{allowedToReport && <ReportButton handleClose={handleClose} isReported={isReported} tweetId={id} />}
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import React, { memo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar,
|
||||
ListItem,
|
||||
Typography,
|
||||
} from '@material-ui/core';
|
||||
import { ListItemAvatar, Avatar as MuiAvatar, ListItem, Typography } from '@material-ui/core';
|
||||
import { secondsToHumanReadable } from '../../utils/time';
|
||||
import LikeButton from '../buttons/LikeButton';
|
||||
import ReplyButton from '../buttons/ReplyButton';
|
||||
@@ -61,17 +56,7 @@ const useStyles = makeStyles(() => ({
|
||||
}));
|
||||
|
||||
export const Tweet = (tweet) => {
|
||||
const {
|
||||
id,
|
||||
message,
|
||||
images,
|
||||
avatar_url,
|
||||
profile_name,
|
||||
seconds_since_tweet,
|
||||
isLiked,
|
||||
isMine,
|
||||
isReported,
|
||||
} = tweet;
|
||||
const { id, message, images, avatar_url, profile_name, seconds_since_tweet, isLiked, isMine, isReported } = tweet;
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const { config } = usePhone();
|
||||
@@ -105,12 +90,7 @@ export const Tweet = (tweet) => {
|
||||
<div className={classes.content}>
|
||||
<div className={classes.primary}>
|
||||
<div className={classes.profile}>{profileName}</div>
|
||||
<Typography
|
||||
className={classes.date}
|
||||
component="div"
|
||||
variant="body2"
|
||||
color="textSecondary"
|
||||
>
|
||||
<Typography className={classes.date} component="div" variant="body2" color="textSecondary">
|
||||
{secondsToHumanReadable(t, seconds_since_tweet)}
|
||||
</Typography>
|
||||
</div>
|
||||
|
||||
@@ -51,14 +51,10 @@ export const TweetMessage = ({ modalVisible, message, handleChange }) => {
|
||||
let errorMessage = null;
|
||||
|
||||
const overCharacterLimit = message.trim().length > characterLimit;
|
||||
const characterWarningPrompt = `${t(
|
||||
'APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT',
|
||||
)} (${characterLimit})`;
|
||||
const characterWarningPrompt = `${t('APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT')} (${characterLimit})`;
|
||||
|
||||
const overNewLineLimit = getNewLineCount(message) > newLineLimit;
|
||||
const newLineWarningPrompt = `${t(
|
||||
'APPS_TWITTER_TWEET_MESSAGE_NEW_LINE_LIMIT',
|
||||
)} (${newLineLimit})`;
|
||||
const newLineWarningPrompt = `${t('APPS_TWITTER_TWEET_MESSAGE_NEW_LINE_LIMIT')} (${newLineLimit})`;
|
||||
|
||||
if (overCharacterLimit) {
|
||||
errorMessage = characterWarningPrompt;
|
||||
|
||||
@@ -2,9 +2,7 @@ import { useRecoilState } from 'recoil';
|
||||
import { twitterState } from './state';
|
||||
|
||||
export const useModal = () => {
|
||||
const [modalVisible, setModalVisible] = useRecoilState(
|
||||
twitterState.showCreateTweetModal,
|
||||
);
|
||||
const [modalVisible, setModalVisible] = useRecoilState(twitterState.showCreateTweetModal);
|
||||
const [message, setMessage] = useRecoilState(twitterState.modalMessage);
|
||||
return { modalVisible, setModalVisible, message, setMessage };
|
||||
};
|
||||
@@ -19,9 +19,7 @@ interface IUseProfile {
|
||||
export const useProfile = (): IUseProfile => {
|
||||
const profile = useRecoilValue(twitterState.profile);
|
||||
const updateProfileLoading = useRecoilValue(twitterState.updateProfileLoading);
|
||||
const [updateProfileSuccessful, setUpdateProfileSuccessful] = useRecoilState(
|
||||
twitterState.updateProfileSuccess,
|
||||
);
|
||||
const [updateProfileSuccessful, setUpdateProfileSuccessful] = useRecoilState(twitterState.updateProfileSuccess);
|
||||
return {
|
||||
profile,
|
||||
updateProfileLoading,
|
||||
|
||||
@@ -4,9 +4,7 @@ import { twitterState } from './state';
|
||||
|
||||
export const useTweetStatus = () => {
|
||||
const createTweetLoading = useRecoilValue(twitterState.createTweetLoading);
|
||||
const [createTweetSuccessful, setCreateTweetSuccessful] = useRecoilState(
|
||||
twitterState.createTweetSuccessful,
|
||||
);
|
||||
const [createTweetSuccessful, setCreateTweetSuccessful] = useRecoilState(twitterState.createTweetSuccessful);
|
||||
return {
|
||||
createTweetLoading,
|
||||
createTweetSuccessful,
|
||||
|
||||
@@ -12,10 +12,7 @@ const DAYS = 'APPS_TWITTER_TIME_DAYS';
|
||||
* @param {function} t - translation object passed from a component implementing the hook
|
||||
* @param {number} seconds - seconds to translate to a string
|
||||
*/
|
||||
export function secondsToHumanReadable(
|
||||
t: (input: string) => string,
|
||||
seconds: number,
|
||||
): string {
|
||||
export function secondsToHumanReadable(t: (input: string) => string, seconds: number): string {
|
||||
if (seconds < 60) {
|
||||
return t(JUST_NOW);
|
||||
} else if (seconds < ONE_HOUR) {
|
||||
|
||||
@@ -6,10 +6,7 @@ interface IRouterLocation {
|
||||
search: any;
|
||||
}
|
||||
|
||||
export const deleteQueryFromLocation = (
|
||||
location: Record<string, unknown> & IRouterLocation,
|
||||
key = '',
|
||||
) => {
|
||||
export const deleteQueryFromLocation = (location: Record<string, unknown> & IRouterLocation, key = '') => {
|
||||
const { query } = url(location.pathname + location.search);
|
||||
return `${location.pathname}/?${qs.stringify({
|
||||
...query,
|
||||
|
||||
@@ -19,15 +19,7 @@
|
||||
"printDebugLogs": true,
|
||||
"logLevel": 1
|
||||
},
|
||||
"frames": [
|
||||
"default.png",
|
||||
"blue.png",
|
||||
"gold.png",
|
||||
"kawaii.png",
|
||||
"minimal.png",
|
||||
"pink.png",
|
||||
"white.png"
|
||||
],
|
||||
"frames": ["default.png", "blue.png", "gold.png", "kawaii.png", "minimal.png", "pink.png", "white.png"],
|
||||
"zoomOptions": [1, 0.9, 0.8],
|
||||
"ringtones": ["marimba", "pixel"],
|
||||
"notifications": ["online", "99kr"],
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
|
||||
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
||||
'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
font-size: 20px;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import React from 'react';
|
||||
import { blue, common, grey, purple } from '@material-ui/core/colors';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import {
|
||||
faAd,
|
||||
faPlaneArrival,
|
||||
faPhoneAlt,
|
||||
faWonSign,
|
||||
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';
|
||||
@@ -28,26 +22,11 @@ import { NotesApp } from '../../../apps/notes/NotesApp';
|
||||
import CameraApp from '../../../apps/camera/components/CameraApp';
|
||||
import { AppRoute } from '../components/AppRoute';
|
||||
|
||||
import {
|
||||
MESSAGES_APP_PRIMARY_COLOR,
|
||||
MESSAGES_APP_TEXT_COLOR,
|
||||
} from '../../../apps/messages/messages.theme';
|
||||
import {
|
||||
CONTACTS_APP_PRIMARY_COLOR,
|
||||
CONTACTS_APP_TEXT_COLOR,
|
||||
} from '../../../apps/contacts/contacts.theme';
|
||||
import {
|
||||
SELLOUT_APP_PRIMARY_COLOR,
|
||||
SELLOUT_APP_ICON_COLOR,
|
||||
} from '../../../apps/sellout/sellout.theme';
|
||||
import {
|
||||
NOTES_APP_ICON_COLOR,
|
||||
NOTES_APP_PRIMARY_COLOR,
|
||||
} from '../../../apps/notes/notes.theme';
|
||||
import {
|
||||
DIALER_APP_PRIMARY_COLOR,
|
||||
DIALER_APP_TEXT_COLOR,
|
||||
} from '../../../apps/dialer/dialer.theme';
|
||||
import { MESSAGES_APP_PRIMARY_COLOR, MESSAGES_APP_TEXT_COLOR } from '../../../apps/messages/messages.theme';
|
||||
import { CONTACTS_APP_PRIMARY_COLOR, CONTACTS_APP_TEXT_COLOR } from '../../../apps/contacts/contacts.theme';
|
||||
import { SELLOUT_APP_PRIMARY_COLOR, SELLOUT_APP_ICON_COLOR } from '../../../apps/sellout/sellout.theme';
|
||||
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
|
||||
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
|
||||
|
||||
export interface IAppConfig {
|
||||
id: string;
|
||||
@@ -99,9 +78,7 @@ export const APPS: IAppConfig[] = [
|
||||
backgroundColor: purple[500],
|
||||
color: grey[50],
|
||||
path: '/calculator',
|
||||
Route: () => (
|
||||
<AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />,
|
||||
},
|
||||
{
|
||||
id: 'SETTINGS',
|
||||
|
||||
@@ -12,10 +12,7 @@ export const useApps = () => {
|
||||
})),
|
||||
[icons],
|
||||
);
|
||||
const getApp = useCallback(
|
||||
(id: string): IAppConfig => apps.find((a) => a.id === id) || null,
|
||||
[apps],
|
||||
);
|
||||
const getApp = useCallback((id: string): IAppConfig => apps.find((a) => a.id === id) || null, [apps]);
|
||||
return { apps, getApp };
|
||||
};
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@ import { callerState } from './state';
|
||||
export const useDuration = () => {
|
||||
const [duration, setDuration] = useRecoilState(callerState.callDuration);
|
||||
|
||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [
|
||||
setDuration,
|
||||
]);
|
||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [setDuration]);
|
||||
|
||||
return { duration, setDuration, resetDuration };
|
||||
};
|
||||
@@ -34,15 +34,7 @@ const keyboardState = {
|
||||
}),
|
||||
};
|
||||
|
||||
const validKeys = [
|
||||
'ArrowRight',
|
||||
'ArrowLeft',
|
||||
'ArrowUp',
|
||||
'ArrowDown',
|
||||
'Backspace',
|
||||
'Enter',
|
||||
'Escape',
|
||||
];
|
||||
const validKeys = ['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Backspace', 'Enter', 'Escape'];
|
||||
|
||||
const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
|
||||
|
||||
|
||||
@@ -28,16 +28,8 @@ export const Navigation = () => {
|
||||
value();
|
||||
}}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
label="Home"
|
||||
value={() => history.push('/')}
|
||||
icon={<AppsIcon />}
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
label="Close"
|
||||
value={closePhone}
|
||||
icon={<RadioButtonUncheckedIcon />}
|
||||
/>
|
||||
<BottomNavigationAction label="Home" value={() => history.push('/')} icon={<AppsIcon />} />
|
||||
<BottomNavigationAction label="Close" value={closePhone} icon={<RadioButtonUncheckedIcon />} />
|
||||
<BottomNavigationAction
|
||||
label="Back"
|
||||
value={() => !isExact && history.goBack()}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
Grid,
|
||||
IconButton,
|
||||
Slide,
|
||||
Paper,
|
||||
Box,
|
||||
List,
|
||||
Divider,
|
||||
} from '@material-ui/core';
|
||||
import { makeStyles, Typography, Grid, IconButton, Slide, Paper, Box, List, Divider } from '@material-ui/core';
|
||||
import SignalIcon from '@material-ui/icons/SignalCellular3Bar';
|
||||
import Battery90Icon from '@material-ui/icons/Battery90';
|
||||
import ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp';
|
||||
@@ -66,13 +56,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
export const NotificationBar = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
const {
|
||||
icons,
|
||||
notifications,
|
||||
removeNotification,
|
||||
barUncollapsed,
|
||||
setBarUncollapsed,
|
||||
} = useNotifications();
|
||||
const { icons, notifications, removeNotification, barUncollapsed, setBarUncollapsed } = useNotifications();
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -87,12 +71,7 @@ export const NotificationBar = () => {
|
||||
>
|
||||
<Grid container item wrap="nowrap">
|
||||
{icons.map((notifIcon) => (
|
||||
<Grid
|
||||
item
|
||||
key={notifIcon.key}
|
||||
component={IconButton}
|
||||
className={classes.icon}
|
||||
>
|
||||
<Grid item key={notifIcon.key} component={IconButton} className={classes.icon}>
|
||||
{notifIcon.icon}
|
||||
</Grid>
|
||||
))}
|
||||
@@ -139,11 +118,7 @@ export const NotificationBar = () => {
|
||||
</List>
|
||||
</Box>
|
||||
<Box display="flex">
|
||||
<IconButton
|
||||
className={classes.collapseBtn}
|
||||
size="small"
|
||||
onClick={() => setBarUncollapsed(false)}
|
||||
>
|
||||
<IconButton className={classes.collapseBtn} size="small" onClick={() => setBarUncollapsed(false)}>
|
||||
<ArrowDropUpIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import React from 'react';
|
||||
import CloseIcon from '@material-ui/icons/Close';
|
||||
import {
|
||||
IconButton,
|
||||
ListItem,
|
||||
ListItemAvatar,
|
||||
ListItemText,
|
||||
makeStyles,
|
||||
Theme,
|
||||
} from '@material-ui/core';
|
||||
import { IconButton, ListItem, ListItemAvatar, ListItemText, makeStyles, Theme } from '@material-ui/core';
|
||||
import { INotification } from '../providers/NotificationsProvider';
|
||||
|
||||
const useStyles = makeStyles<Theme, { cantClose: boolean }>((theme) => ({
|
||||
|
||||
@@ -25,9 +25,7 @@ const unshiftApp = (arr: IAppConfig[], app) => {
|
||||
export const useQuickAccess = () => {
|
||||
const history = useHistory();
|
||||
const { apps, getApp } = useApps();
|
||||
const [recentlyUsed, setRecentlyUsed] = useRecoilState<IAppConfig[]>(
|
||||
state.recentlyUsed,
|
||||
);
|
||||
const [recentlyUsed, setRecentlyUsed] = useRecoilState<IAppConfig[]>(state.recentlyUsed);
|
||||
|
||||
useEffect(() => {
|
||||
setRecentlyUsed([getApp('SETTINGS')]);
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import React, {
|
||||
createContext,
|
||||
useState,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useRef,
|
||||
useEffect,
|
||||
} from 'react';
|
||||
import React, { createContext, useState, useCallback, useMemo, useRef, useEffect } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||
import { phoneState } from '../../phone/hooks/state';
|
||||
@@ -53,11 +46,7 @@ export const NotificationsContext = createContext<{
|
||||
updateId(id: string, value: Partial<INotification>): void;
|
||||
removeId(id: string): void;
|
||||
hasNotification(app: string): number;
|
||||
addNotificationAlert(
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update?: Partial<INotification>,
|
||||
);
|
||||
addNotificationAlert(n: INotification, persist: boolean, update?: Partial<INotification>);
|
||||
}>(null);
|
||||
|
||||
export function NotificationsProvider({ children }) {
|
||||
@@ -72,9 +61,7 @@ export function NotificationsProvider({ children }) {
|
||||
const { mount, play } = useSoundProvider();
|
||||
|
||||
const alertTimeout = useRef<NodeJS.Timeout>();
|
||||
const [alerts, setAlerts] = useState<
|
||||
Array<[INotification, boolean, Partial<INotification>, string | undefined]>
|
||||
>([]);
|
||||
const [alerts, setAlerts] = useState<Array<[INotification, boolean, Partial<INotification>, string | undefined]>>([]);
|
||||
const [currentAlert, setCurrentAlert] = useState<INotificationAlert>();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -127,12 +114,7 @@ export function NotificationsProvider({ children }) {
|
||||
);
|
||||
|
||||
const _showAlert = useCallback(
|
||||
(
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update: Partial<INotification>,
|
||||
soundUrl: string,
|
||||
) => {
|
||||
(n: INotification, persist: boolean, update: Partial<INotification>, soundUrl: string) => {
|
||||
return new Promise<void>((res) => {
|
||||
const resolve = () => {
|
||||
if (persist) {
|
||||
@@ -172,16 +154,10 @@ export function NotificationsProvider({ children }) {
|
||||
[addOrUpdateNotification, play],
|
||||
);
|
||||
|
||||
const addNotificationAlert = (
|
||||
n: INotification,
|
||||
persist?: boolean,
|
||||
update?: Partial<INotification>,
|
||||
) => {
|
||||
const addNotificationAlert = (n: INotification, persist?: boolean, update?: Partial<INotification>) => {
|
||||
if (n.sound) {
|
||||
const { sound, volume } = getSoundSettings('notification', settings, n.app);
|
||||
mount(sound, volume, false).then(({ url }) =>
|
||||
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
||||
);
|
||||
mount(sound, volume, false).then(({ url }) => setAlerts((curr) => [...curr, [n, persist, update, url]]));
|
||||
return;
|
||||
}
|
||||
setAlerts((curr) => [...curr, [n, persist, update, undefined]]);
|
||||
|
||||
@@ -21,16 +21,7 @@ const useSound = (url: string, options: ISoundOptions = DEFAULT_OPTIONS) => {
|
||||
|
||||
const [isPlaying, setPlaying] = useState<boolean>(false);
|
||||
|
||||
const {
|
||||
mount,
|
||||
play,
|
||||
stop,
|
||||
playing,
|
||||
volume,
|
||||
loop,
|
||||
remove,
|
||||
isMounted,
|
||||
} = useSoundProvider();
|
||||
const { mount, play, stop, playing, volume, loop, remove, isMounted } = useSoundProvider();
|
||||
|
||||
const previousInterrupt = usePreviousState(interrupt);
|
||||
const previousUrl = usePreviousState(url);
|
||||
@@ -50,20 +41,7 @@ const useSound = (url: string, options: ISoundOptions = DEFAULT_OPTIONS) => {
|
||||
}
|
||||
volume(url, vol);
|
||||
loop(url, isLoop);
|
||||
}, [
|
||||
url,
|
||||
vol,
|
||||
isLoop,
|
||||
isMounted,
|
||||
volume,
|
||||
loop,
|
||||
mount,
|
||||
previousUrl,
|
||||
stop,
|
||||
remove,
|
||||
isPlaying,
|
||||
play,
|
||||
]);
|
||||
}, [url, vol, isLoop, isMounted, volume, loop, mount, previousUrl, stop, remove, isPlaying, play]);
|
||||
|
||||
useEffect(() => {
|
||||
if (interrupt) {
|
||||
|
||||
@@ -7,12 +7,7 @@ interface IMountResponse {
|
||||
}
|
||||
|
||||
interface ISoundContext {
|
||||
mount(
|
||||
url: string,
|
||||
volume?: number,
|
||||
loop?: boolean,
|
||||
autoplay?: boolean,
|
||||
): Promise<IMountResponse>;
|
||||
mount(url: string, volume?: number, loop?: boolean, autoplay?: boolean): Promise<IMountResponse>;
|
||||
play(url?: string, volume?: number, loop?: boolean): void;
|
||||
stop(url: string): void;
|
||||
remove(url: string): boolean;
|
||||
@@ -31,55 +26,47 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
soundRefs.current = new Map();
|
||||
}, []);
|
||||
|
||||
const mount = useCallback(
|
||||
(
|
||||
url: string,
|
||||
volume: number = 1,
|
||||
loop: boolean = false,
|
||||
autoplay: boolean = false,
|
||||
) => {
|
||||
return new Promise<IMountResponse>((res) => {
|
||||
if (!soundRefs.current) {
|
||||
soundRefs.current = new Map();
|
||||
const mount = useCallback((url: string, volume: number = 1, loop: boolean = false, autoplay: boolean = false) => {
|
||||
return new Promise<IMountResponse>((res) => {
|
||||
if (!soundRefs.current) {
|
||||
soundRefs.current = new Map();
|
||||
}
|
||||
|
||||
const find = soundRefs.current.get(url);
|
||||
|
||||
if (find) {
|
||||
find.howl.volume(volume);
|
||||
find.howl.loop(loop);
|
||||
if (autoplay) {
|
||||
find.howl.play();
|
||||
}
|
||||
return res({ howl: find.howl, url });
|
||||
}
|
||||
|
||||
const find = soundRefs.current.get(url);
|
||||
|
||||
if (find) {
|
||||
find.howl.volume(volume);
|
||||
find.howl.loop(loop);
|
||||
if (autoplay) {
|
||||
find.howl.play();
|
||||
}
|
||||
return res({ howl: find.howl, url });
|
||||
}
|
||||
|
||||
const instance = new Howl({
|
||||
src: url,
|
||||
loop,
|
||||
volume,
|
||||
autoplay,
|
||||
});
|
||||
|
||||
soundRefs.current.set(url, { howl: instance, volume });
|
||||
|
||||
instance.once('load', () => {
|
||||
console.log('ready', instance);
|
||||
res({ howl: instance, url });
|
||||
});
|
||||
|
||||
const onError = (_id, e) => {
|
||||
res(null);
|
||||
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
|
||||
};
|
||||
|
||||
instance.once('loaderror', onError);
|
||||
|
||||
instance.once('playerror', onError);
|
||||
const instance = new Howl({
|
||||
src: url,
|
||||
loop,
|
||||
volume,
|
||||
autoplay,
|
||||
});
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
soundRefs.current.set(url, { howl: instance, volume });
|
||||
|
||||
instance.once('load', () => {
|
||||
console.log('ready', instance);
|
||||
res({ howl: instance, url });
|
||||
});
|
||||
|
||||
const onError = (_id, e) => {
|
||||
res(null);
|
||||
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
|
||||
};
|
||||
|
||||
instance.once('loaderror', onError);
|
||||
|
||||
instance.once('playerror', onError);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const play = useCallback(
|
||||
(url: string, volume: number, loop: boolean) => {
|
||||
@@ -167,9 +154,7 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<soundContext.Provider
|
||||
value={{ mount, play, stop, playing, remove, volume, loop, isMounted }}
|
||||
>
|
||||
<soundContext.Provider value={{ mount, play, stop, playing, remove, volume, loop, isMounted }}>
|
||||
{children}
|
||||
</soundContext.Provider>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { IPhoneSettings } from '../../../apps/settings/hooks/useSettings';
|
||||
import {
|
||||
getNotificationPath,
|
||||
getRingtonePath,
|
||||
} from '../../../apps/settings/utils/getRingtonePath';
|
||||
import { getNotificationPath, getRingtonePath } from '../../../apps/settings/utils/getRingtonePath';
|
||||
|
||||
const getPath = {
|
||||
ringtone: getRingtonePath,
|
||||
@@ -12,11 +9,7 @@ const getPath = {
|
||||
/**
|
||||
* Gets the configuration for SoundProvider based on settings and apps
|
||||
*/
|
||||
export const getSoundSettings = (
|
||||
type: 'ringtone' | 'notification',
|
||||
settings: IPhoneSettings,
|
||||
app?: string,
|
||||
) => {
|
||||
export const getSoundSettings = (type: 'ringtone' | 'notification', settings: IPhoneSettings, app?: string) => {
|
||||
try {
|
||||
return app
|
||||
? {
|
||||
|
||||
@@ -23,23 +23,13 @@ const useStyles = makeStyles(() => ({
|
||||
},
|
||||
}));
|
||||
|
||||
export const AppContent = ({
|
||||
children,
|
||||
style,
|
||||
backdrop,
|
||||
onClickBackdrop,
|
||||
...props
|
||||
}: AppContentTypes & BoxProps) => {
|
||||
export const AppContent = ({ children, style, backdrop, onClickBackdrop, ...props }: AppContentTypes & BoxProps) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.wrapper} square>
|
||||
<Box flexGrow={1} className={classes.box} {...props}>
|
||||
<Paper square elevation={0} className={classes.paper}>
|
||||
<Backdrop
|
||||
className={classes.backdrop}
|
||||
open={backdrop || false}
|
||||
onClick={onClickBackdrop}
|
||||
/>
|
||||
<Backdrop className={classes.backdrop} open={backdrop || false} onClick={onClickBackdrop} />
|
||||
{children}
|
||||
</Paper>
|
||||
</Box>
|
||||
|
||||
@@ -5,38 +5,28 @@ import { green } from '@material-ui/core/colors';
|
||||
import { Badge, Button, Tooltip, Zoom } from '@material-ui/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const useStyles = makeStyles<Theme, { color: string; backgroundColor: string }>(
|
||||
(theme) => ({
|
||||
root: {
|
||||
padding: 0,
|
||||
marginTop: theme.spacing(3),
|
||||
const useStyles = makeStyles<Theme, { color: string; backgroundColor: string }>((theme) => ({
|
||||
root: {
|
||||
padding: 0,
|
||||
marginTop: theme.spacing(3),
|
||||
},
|
||||
avatar: {
|
||||
'&:hover': {
|
||||
backgroundColor: ({ backgroundColor }) => darken(backgroundColor, 0.1),
|
||||
},
|
||||
avatar: {
|
||||
'&:hover': {
|
||||
backgroundColor: ({ backgroundColor }) => darken(backgroundColor, 0.1),
|
||||
},
|
||||
backgroundColor: ({ backgroundColor }) => backgroundColor,
|
||||
color: ({ color }) => color,
|
||||
boxShadow: theme.shadows[2],
|
||||
width: theme.spacing(8),
|
||||
height: theme.spacing(8),
|
||||
fontSize: theme.typography.h4.fontSize,
|
||||
},
|
||||
tooltip: {
|
||||
fontSize: 12,
|
||||
},
|
||||
}),
|
||||
);
|
||||
backgroundColor: ({ backgroundColor }) => backgroundColor,
|
||||
color: ({ color }) => color,
|
||||
boxShadow: theme.shadows[2],
|
||||
width: theme.spacing(8),
|
||||
height: theme.spacing(8),
|
||||
fontSize: theme.typography.h4.fontSize,
|
||||
},
|
||||
tooltip: {
|
||||
fontSize: 12,
|
||||
},
|
||||
}));
|
||||
|
||||
export const AppIcon = ({
|
||||
id,
|
||||
nameLocale,
|
||||
name,
|
||||
icon,
|
||||
backgroundColor,
|
||||
color,
|
||||
notification,
|
||||
}) => {
|
||||
export const AppIcon = ({ id, nameLocale, name, icon, backgroundColor, color, notification }) => {
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles({
|
||||
backgroundColor: backgroundColor || green[50],
|
||||
@@ -53,11 +43,7 @@ export const AppIcon = ({
|
||||
TransitionComponent={Zoom}
|
||||
>
|
||||
<Button className={classes.root}>
|
||||
<Badge
|
||||
color="error"
|
||||
badgeContent={notification?.badge}
|
||||
invisible={!notification || notification.badge < 2}
|
||||
>
|
||||
<Badge color="error" badgeContent={notification?.badge} invisible={!notification || notification.badge < 2}>
|
||||
<Avatar className={classes.avatar}>{icon || name[0].toUpperCase()}</Avatar>
|
||||
</Badge>
|
||||
</Button>
|
||||
|
||||
@@ -28,11 +28,7 @@ const useStyle = makeStyles(
|
||||
);
|
||||
// Taso: Maybe we should pass an icon (maybe fa?) as a prop as well at somepoint
|
||||
// but need to think about the best way to do that for standardization sake.
|
||||
export const AppTitle = ({
|
||||
app: { backgroundColor, color, nameLocale },
|
||||
variant = 'h5',
|
||||
...props
|
||||
}: IProps) => {
|
||||
export const AppTitle = ({ app: { backgroundColor, color, nameLocale }, variant = 'h5', ...props }: IProps) => {
|
||||
const classes = useStyle({ color, backgroundColor });
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import React from 'react';
|
||||
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
||||
|
||||
export const AppWrapper = ({
|
||||
children,
|
||||
style,
|
||||
handleClickAway,
|
||||
...props
|
||||
}: AppWrapperTypes) => {
|
||||
export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWrapperTypes) => {
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
|
||||
@@ -17,11 +17,9 @@ const useStyles = makeStyles(
|
||||
},
|
||||
},
|
||||
outlined: {
|
||||
border: ({ color }: IStatusButtonStyleProps) =>
|
||||
`1px solid ${fade(theme.palette[color].main, 0.5)}`,
|
||||
border: ({ color }: IStatusButtonStyleProps) => `1px solid ${fade(theme.palette[color].main, 0.5)}`,
|
||||
'&:hover': {
|
||||
border: ({ color }: IStatusButtonStyleProps) =>
|
||||
`1px solid ${theme.palette[color].main}`,
|
||||
border: ({ color }: IStatusButtonStyleProps) => `1px solid ${theme.palette[color].main}`,
|
||||
},
|
||||
'&$disabled': {
|
||||
border: `1px solid ${theme.palette.action.disabled}`,
|
||||
@@ -31,8 +29,7 @@ const useStyles = makeStyles(
|
||||
color: ({ color }: IStatusButtonStyleProps) => theme.palette[color].contrastText,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].main,
|
||||
'&:hover': {
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||
theme.palette[color].dark,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].dark,
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -46,11 +43,5 @@ export const StatusButton = ({
|
||||
...props
|
||||
}: Omit<ButtonProps, 'color'> & { color: StatusButtonStyleColor }) => {
|
||||
const classes = useStyles({ color });
|
||||
return (
|
||||
<Button
|
||||
variant={variant}
|
||||
className={`${classes.root} ${classes[variant] || ''} ${className}`}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
return <Button variant={variant} className={`${classes.root} ${classes[variant] || ''} ${className}`} {...props} />;
|
||||
};
|
||||
@@ -13,16 +13,13 @@ const useStyles = makeStyles(
|
||||
color: ({ color }: IStatusButtonStyleProps) => theme.palette[color].contrastText,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].main,
|
||||
'&:hover': {
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||
theme.palette[color].light,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].light,
|
||||
},
|
||||
},
|
||||
outlined: {
|
||||
border: ({ color }: IStatusButtonStyleProps) =>
|
||||
`1px solid ${fade(theme.palette[color].main, 0.5)}`,
|
||||
border: ({ color }: IStatusButtonStyleProps) => `1px solid ${fade(theme.palette[color].main, 0.5)}`,
|
||||
'&:hover': {
|
||||
border: ({ color }: IStatusButtonStyleProps) =>
|
||||
`1px solid ${theme.palette[color].main}`,
|
||||
border: ({ color }: IStatusButtonStyleProps) => `1px solid ${theme.palette[color].main}`,
|
||||
},
|
||||
'&$disabled': {
|
||||
border: `1px solid ${theme.palette.action.disabled}`,
|
||||
@@ -32,8 +29,7 @@ const useStyles = makeStyles(
|
||||
color: ({ color }: IStatusButtonStyleProps) => theme.palette[color].contrastText,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].main,
|
||||
'&:hover': {
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) =>
|
||||
theme.palette[color].dark,
|
||||
backgroundColor: ({ color }: IStatusButtonStyleProps) => theme.palette[color].dark,
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -23,10 +23,5 @@ export const useContextMenu = (_options?): UseContextMenu => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
return [
|
||||
onOpen,
|
||||
onClose,
|
||||
() => <ContextMenu open={open} onClose={onClose} options={options} />,
|
||||
open,
|
||||
];
|
||||
return [onOpen, onClose, () => <ContextMenu open={open} onClose={onClose} options={options} />, open];
|
||||
};
|
||||
@@ -16,11 +16,7 @@ function SnackbarProvider({ children }) {
|
||||
return () => clearTimeout(timer.current);
|
||||
}, [alert]);
|
||||
|
||||
return (
|
||||
<SnackbarContext.Provider value={{ alert, addAlert: setAlert }}>
|
||||
{children}
|
||||
</SnackbarContext.Provider>
|
||||
);
|
||||
return <SnackbarContext.Provider value={{ alert, addAlert: setAlert }}>{children}</SnackbarContext.Provider>;
|
||||
}
|
||||
|
||||
export default SnackbarProvider;
|
||||
@@ -1,6 +1,3 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
['@babel/preset-env', { targets: { node: 'current' } }],
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
|
||||
};
|
||||
+33
-39
@@ -11,26 +11,23 @@ on(`__cfx_nui:${events.PHONE_INITIALIZE_CALL}`, (data: any, cb: Function) => {
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.PHONE_START_CALL,
|
||||
(transmitter: string, receiver: string, isTransmitter: boolean) => {
|
||||
openCallModal(true);
|
||||
onNet(events.PHONE_START_CALL, (transmitter: string, receiver: string, isTransmitter: boolean) => {
|
||||
openCallModal(true);
|
||||
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: transmitter,
|
||||
receiver: receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
SendNuiMessage(
|
||||
JSON.stringify({
|
||||
app: 'CALL',
|
||||
method: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: transmitter,
|
||||
receiver: receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_ACCEPT_CALL); // Fires when the TARGET accepts.
|
||||
on(`__cfx_nui:${events.PHONE_ACCEPT_CALL}`, (data: any, cb: Function) => {
|
||||
@@ -38,26 +35,23 @@ on(`__cfx_nui:${events.PHONE_ACCEPT_CALL}`, (data: any, cb: Function) => {
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.PHONE_CALL_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: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: currentCall.transmitter,
|
||||
receiver: currentCall.receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
onNet(events.PHONE_CALL_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: 'setCaller',
|
||||
data: {
|
||||
active: true,
|
||||
transmitter: currentCall.transmitter,
|
||||
receiver: currentCall.receiver,
|
||||
isTransmitter: isTransmitter,
|
||||
accepted: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
RegisterNuiCallbackType(events.PHONE_CALL_REJECTED); // Fires when cancelling and rejecting a call.
|
||||
on(`__cfx_nui:${events.PHONE_CALL_REJECTED}`, (data: any, cb: Function) => {
|
||||
|
||||
@@ -10,13 +10,10 @@ on(`__cfx_nui:${events.MESSAGES_FETCH_MESSAGE_GROUPS}`, (): void => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS);
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS,
|
||||
(messageGroups: MessageGroup[]): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, messageGroups);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS);
|
||||
},
|
||||
);
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, (messageGroups: MessageGroup[]): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS, messageGroups);
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_SUCCESS);
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, () => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED);
|
||||
@@ -26,13 +23,10 @@ onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS_FAILED, () => {
|
||||
* Messages create message group
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_CREATE_MESSAGE_GROUP);
|
||||
on(
|
||||
`__cfx_nui:${events.MESSAGES_CREATE_MESSAGE_GROUP}`,
|
||||
({ phoneNumbers, label }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP, phoneNumbers, label);
|
||||
cb();
|
||||
},
|
||||
);
|
||||
on(`__cfx_nui:${events.MESSAGES_CREATE_MESSAGE_GROUP}`, ({ phoneNumbers, label }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP, phoneNumbers, label);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, (result: any): void => {
|
||||
sendMessageEvent(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, result);
|
||||
@@ -47,13 +41,10 @@ onNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, (result: any): void => {
|
||||
* Messages fetch messages
|
||||
*/
|
||||
RegisterNuiCallbackType(events.MESSAGES_FETCH_MESSAGES);
|
||||
on(
|
||||
`__cfx_nui:${events.MESSAGES_FETCH_MESSAGES}`,
|
||||
({ groupId }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGES, groupId);
|
||||
cb();
|
||||
},
|
||||
);
|
||||
on(`__cfx_nui:${events.MESSAGES_FETCH_MESSAGES}`, ({ groupId }: any, cb: Function): void => {
|
||||
emitNet(events.MESSAGES_FETCH_MESSAGES, groupId);
|
||||
cb();
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGES_SUCCESS, (messages: Message[]): void => {
|
||||
sendMessageEvent(events.MESSAGES_FETCH_MESSAGES_SUCCESS, messages);
|
||||
|
||||
@@ -24,23 +24,7 @@ const newPhoneProp = async () => {
|
||||
prop = CreateObject(GetHashKey(phoneModel), x, y, z + 0.2, true, true, true);
|
||||
//prop = CreateObject(GetHashKey(phoneModel), 1.0, 1.0, 1.0, 1, 1, 0)
|
||||
const boneIndex = GetPedBoneIndex(playerPed, 28422);
|
||||
AttachEntityToEntity(
|
||||
prop,
|
||||
playerPed,
|
||||
boneIndex,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
-0.0,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
1.0,
|
||||
true,
|
||||
); //-- Attaches the phone to the player.
|
||||
AttachEntityToEntity(prop, playerPed, boneIndex, 0.0, 0.0, 0.0, 0.0, 0.0, -0.0, true, true, false, true, 1.0, true); //-- Attaches the phone to the player.
|
||||
propCreated = true;
|
||||
} else if (propCreated) {
|
||||
console.log('prop already created');
|
||||
@@ -77,19 +61,7 @@ const handleOpenVehicleAnim = async (playerPed: number): Promise<void> => {
|
||||
SetCurrentPedWeapon(playerPed, 0xa2719263, true);
|
||||
ClearPedTasks(playerPed);
|
||||
await loadAnimDict(dict);
|
||||
TaskPlayAnim(
|
||||
playerPed,
|
||||
dict,
|
||||
'cellphone_text_in',
|
||||
7.0,
|
||||
-1,
|
||||
-1,
|
||||
50,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
TaskPlayAnim(playerPed, dict, 'cellphone_text_in', 7.0, -1, -1, 50, 0, false, false, false);
|
||||
await Delay(300);
|
||||
await newPhoneProp();
|
||||
};
|
||||
@@ -101,19 +73,7 @@ const handleOpenNormalAnim = async (playerPed: number): Promise<void> => {
|
||||
SetCurrentPedWeapon(playerPed, 0xa2719263, true);
|
||||
ClearPedTasks(playerPed);
|
||||
await loadAnimDict(dict);
|
||||
TaskPlayAnim(
|
||||
playerPed,
|
||||
dict,
|
||||
'cellphone_text_in',
|
||||
8.0,
|
||||
-1,
|
||||
-1,
|
||||
50,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
TaskPlayAnim(playerPed, dict, 'cellphone_text_in', 8.0, -1, -1, 50, 0, false, false, false);
|
||||
await Delay(300);
|
||||
await newPhoneProp();
|
||||
};
|
||||
|
||||
@@ -13,9 +13,7 @@ import { mainLogger } from './sv_logger';
|
||||
// we require set mysql_connection_string to be set in the config
|
||||
const mysqlConnectionString = GetConvar(CONNECTION_STRING, 'none');
|
||||
if (mysqlConnectionString === 'none') {
|
||||
const error = new Error(
|
||||
`No connection string provided. make sure "${CONNECTION_STRING}" is set in your config.`,
|
||||
);
|
||||
const error = new Error(`No connection string provided. make sure "${CONNECTION_STRING}" is set in your config.`);
|
||||
mainLogger.error(error.message);
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ interface Map {
|
||||
export function parseSemiColonFormat(connectionString: string): Map {
|
||||
const parts = connectionString.split(';');
|
||||
if (parts.length === 1) {
|
||||
throw new Error(
|
||||
`Connection string ${connectionString} is in the incorrect format. Please follow the README.`,
|
||||
);
|
||||
throw new Error(`Connection string ${connectionString} is in the incorrect format. Please follow the README.`);
|
||||
}
|
||||
|
||||
return parts.reduce((connectionInfo: Map, part) => {
|
||||
|
||||
@@ -15,10 +15,7 @@ const DISCORD_HEADERS = { authorization: `Bot ${DISCORD_TOKEN}` };
|
||||
const BASE_URL = 'https://discord.com/api';
|
||||
const POST_CHANNEL_URL = `${BASE_URL}/channels/${DISCORD_CHANNEL_ID}/messages`;
|
||||
|
||||
export async function reportTweetToDiscord(
|
||||
tweet: Tweet,
|
||||
reportingProfile: Profile,
|
||||
): Promise<any> {
|
||||
export async function reportTweetToDiscord(tweet: Tweet, reportingProfile: Profile): Promise<any> {
|
||||
if (!DISCORD_TOKEN || !DISCORD_CHANNEL_ID) {
|
||||
discordLogger.warn(`Got a request to report a tweet but discord is not
|
||||
configured. See README on how to configure discord endpoints.`);
|
||||
|
||||
@@ -13,9 +13,7 @@ async function fetchAllTransactions(identifier: string): Promise<Transfer[]> {
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
const transactions = <Transfer[]>results;
|
||||
|
||||
bankLogger.verbose(
|
||||
`Fetched all transactions (${identifier}) - ${JSON.stringify(transactions)}`,
|
||||
);
|
||||
bankLogger.verbose(`Fetched all transactions (${identifier}) - ${JSON.stringify(transactions)}`);
|
||||
|
||||
return transactions;
|
||||
}
|
||||
|
||||
+20
-42
@@ -1,11 +1,6 @@
|
||||
import { ESX } from './server';
|
||||
import events from '../utils/events';
|
||||
import {
|
||||
getIdentifierByPhoneNumber,
|
||||
usePhoneNumber,
|
||||
getIdentifier,
|
||||
getSource,
|
||||
} from './functions';
|
||||
import { getIdentifierByPhoneNumber, usePhoneNumber, getIdentifier, getSource } from './functions';
|
||||
import { XPlayer } from 'esx.js/@types/server';
|
||||
import { ICall } from '../../phone/src/common/typings/call';
|
||||
|
||||
@@ -35,8 +30,7 @@ async function getPlayerFromIdentifier(identifier: string): Promise<XPlayer> {
|
||||
}
|
||||
|
||||
async function saveCall(call: ICall) {
|
||||
const query =
|
||||
'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
|
||||
const query = 'INSERT INTO npwd_calls (identifier, transmitter, receiver, start) VALUES (?, ?, ?, ?)';
|
||||
await pool.query(query, [call.identifier, call.transmitter, call.receiver, call.start]);
|
||||
}
|
||||
|
||||
@@ -46,8 +40,7 @@ async function updateCall(call: ICall, isAccepted: boolean, end: number) {
|
||||
}
|
||||
|
||||
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 calls = <ICall[]>result;
|
||||
return calls;
|
||||
@@ -87,13 +80,7 @@ onNet(events.PHONE_INITIALIZE_CALL, async (phoneNumber: string, timestamp: numbe
|
||||
emitNet(events.PHONE_START_CALL, _source, transmitterNumber, receiverNumber, true);
|
||||
|
||||
// client that is being called
|
||||
emitNet(
|
||||
events.PHONE_START_CALL,
|
||||
xReceiver.source,
|
||||
transmitterNumber,
|
||||
receiverNumber,
|
||||
false,
|
||||
);
|
||||
emitNet(events.PHONE_START_CALL, xReceiver.source, transmitterNumber, receiverNumber, false);
|
||||
});
|
||||
|
||||
onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
@@ -108,13 +95,7 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
emitNet(events.PHONE_CALL_WAS_ACCEPTED, pSource, channelId, currentCall, false);
|
||||
|
||||
// player who is calling
|
||||
emitNet(
|
||||
events.PHONE_CALL_WAS_ACCEPTED,
|
||||
currentCall.transmitterSource,
|
||||
channelId,
|
||||
currentCall,
|
||||
true,
|
||||
);
|
||||
emitNet(events.PHONE_CALL_WAS_ACCEPTED, currentCall.transmitterSource, channelId, currentCall, true);
|
||||
|
||||
currentCall.accepted = true;
|
||||
} catch (e) {
|
||||
@@ -124,25 +105,22 @@ onNet(events.PHONE_ACCEPT_CALL, async (transmitterNumber: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.PHONE_CALL_REJECTED,
|
||||
async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
await updateCall(currentCall, false, timestamp);
|
||||
onNet(events.PHONE_CALL_REJECTED, async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
try {
|
||||
const currentCall = calls.get(transmitterNumber);
|
||||
await updateCall(currentCall, false, timestamp);
|
||||
|
||||
// player who is called and initiasted the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.receiverSource);
|
||||
// player who is calling and recieved the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
||||
} catch (e) {
|
||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
// player who is called and initiasted the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.receiverSource);
|
||||
// player who is calling and recieved the rejection.
|
||||
emitNet(events.PHONE_CALL_WAS_REJECTED, currentCall.transmitterSource);
|
||||
} catch (e) {
|
||||
callLogger.error(`Phone Call Rejected Event Error ${e.message}`, {
|
||||
source: pSource,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.PHONE_END_CALL, async (transmitterNumber: string, timestamp: number) => {
|
||||
const pSource = getSource();
|
||||
|
||||
@@ -18,35 +18,21 @@ interface ContactId {
|
||||
}
|
||||
|
||||
async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
|
||||
const query =
|
||||
'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
|
||||
const query = 'SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC';
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
const contacts = <Contacts[]>results;
|
||||
return contacts;
|
||||
}
|
||||
|
||||
async function addContact(
|
||||
identifier: string,
|
||||
number: string,
|
||||
display: string,
|
||||
avatar: string,
|
||||
): Promise<any> {
|
||||
const query =
|
||||
'INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)';
|
||||
async function addContact(identifier: string, number: string, display: string, avatar: string): Promise<any> {
|
||||
const query = 'INSERT INTO npwd_phone_contacts (identifier, number, display, avatar) VALUES (?, ?, ?, ?)';
|
||||
|
||||
const [result] = await pool.query(query, [identifier, number, display, avatar]);
|
||||
}
|
||||
|
||||
async function updateContact(contact: Contacts, identifier: string): Promise<any> {
|
||||
const query =
|
||||
'UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?';
|
||||
await pool.query(query, [
|
||||
contact.number,
|
||||
contact.display,
|
||||
contact.avatar,
|
||||
contact.id,
|
||||
identifier,
|
||||
]);
|
||||
const query = 'UPDATE npwd_phone_contacts SET number = ?, display = ?, avatar = ? WHERE id = ? AND identifier = ?';
|
||||
await pool.query(query, [contact.number, contact.display, contact.avatar, contact.id, identifier]);
|
||||
}
|
||||
|
||||
async function deleteContact(contact: ContactId, identifier: string): Promise<any> {
|
||||
@@ -66,29 +52,26 @@ onNet(events.CONTACTS_GET_CONTACTS, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.CONTACTS_ADD_CONTACT,
|
||||
async (number: string, display: string, avatar: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
await addContact(_identifier, number, display, avatar);
|
||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
contactsLogger.error(`Failed to add contact, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
onNet(events.CONTACTS_ADD_CONTACT, async (number: string, display: string, avatar: string) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = getIdentifier(_source);
|
||||
await addContact(_identifier, number, display, avatar);
|
||||
emitNet(events.CONTACTS_ADD_CONTACT_SUCCESS, _source);
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_SUCCESS',
|
||||
type: 'success',
|
||||
});
|
||||
} catch (e) {
|
||||
emitNet(events.CONTACTS_ACTION_RESULT, _source, {
|
||||
message: 'CONTACT_ADD_FAILED',
|
||||
type: 'error',
|
||||
});
|
||||
contactsLogger.error(`Failed to add contact, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.CONTACTS_UPDATE_CONTACT, async (contact: Contacts) => {
|
||||
const _source = getSource();
|
||||
|
||||
@@ -7,14 +7,12 @@ const manualColorize = (strToColor: string): string => `[\x1b[35m${strToColor}\x
|
||||
|
||||
// Format handler passed to winston
|
||||
const formatLogs = (log: winston.Logform.TransformableInfo): string => {
|
||||
if (log.module)
|
||||
return `${log.label} ${manualColorize(log.module)} [${log.level}]: ${log.message}`;
|
||||
if (log.module) return `${log.label} ${manualColorize(log.module)} [${log.level}]: ${log.message}`;
|
||||
|
||||
return `${log.label} [${log.level}]: ${log.message}`;
|
||||
};
|
||||
|
||||
const findLogPath = () =>
|
||||
`${path.join(GetResourcePath(GetCurrentResourceName()), 'sv_npwd.log')}`;
|
||||
const findLogPath = () => `${path.join(GetResourcePath(GetCurrentResourceName()), 'sv_npwd.log')}`;
|
||||
// Initiate the main logger for NPWD
|
||||
|
||||
export const mainLogger = winston.createLogger({
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import { ESX } from './server';
|
||||
import { pool } from './db';
|
||||
import config from '../utils/config';
|
||||
import {
|
||||
getIdentifier,
|
||||
getIdentifierByPhoneNumber,
|
||||
getSource,
|
||||
usePhoneNumber,
|
||||
} from './functions';
|
||||
import { getIdentifier, getIdentifierByPhoneNumber, getSource, usePhoneNumber } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
|
||||
//db = DatabaseConfig //helper variable for use in server function
|
||||
|
||||
+65
-106
@@ -1,11 +1,7 @@
|
||||
import md5 from 'md5';
|
||||
|
||||
import events from '../utils/events';
|
||||
import {
|
||||
Message,
|
||||
MessageGroup,
|
||||
CreateMessageGroupResult,
|
||||
} from '../../phone/src/common/typings/messages';
|
||||
import { Message, MessageGroup, CreateMessageGroupResult } from '../../phone/src/common/typings/messages';
|
||||
import { pool, withTransaction } from './db';
|
||||
import { getSource, getIdentifier } from './functions';
|
||||
import { mainLogger } from './sv_logger';
|
||||
@@ -46,11 +42,7 @@ interface MessageGroupMapping {
|
||||
* @param groupId - the message group ID to attach this message to
|
||||
* @param message - content of the message
|
||||
*/
|
||||
async function createMessage(
|
||||
userIdentifier: string,
|
||||
groupId: string,
|
||||
message: string,
|
||||
): Promise<any> {
|
||||
async function createMessage(userIdentifier: string, groupId: string, message: string): Promise<any> {
|
||||
const query = `
|
||||
INSERT INTO npwd_messages
|
||||
(user_identifier, message, group_id)
|
||||
@@ -65,9 +57,7 @@ async function createMessage(
|
||||
* populate the list of message groups on the UI
|
||||
* @param userIdentifier - identifier of the user to get message groups for
|
||||
*/
|
||||
async function getMessageGroups(
|
||||
userIdentifier: string,
|
||||
): Promise<UnformattedMessageGroup[]> {
|
||||
async function getMessageGroups(userIdentifier: string): Promise<UnformattedMessageGroup[]> {
|
||||
const query = `
|
||||
SELECT
|
||||
npwd_messages_groups.group_id,
|
||||
@@ -89,11 +79,7 @@ async function getMessageGroups(
|
||||
WHERE npwd_messages_groups.participant_identifier != ?
|
||||
ORDER BY npwd_messages_groups.createdAt DESC
|
||||
`;
|
||||
const [results] = await pool.query(query, [
|
||||
userIdentifier,
|
||||
userIdentifier,
|
||||
userIdentifier,
|
||||
]);
|
||||
const [results] = await pool.query(query, [userIdentifier, userIdentifier, userIdentifier]);
|
||||
return <UnformattedMessageGroup[]>results;
|
||||
}
|
||||
|
||||
@@ -136,11 +122,7 @@ async function getMessages(userIdentifier: string, groupId: string): Promise<Mes
|
||||
* @param groupId - groupId this label is attached to
|
||||
* @param label - the label itself
|
||||
*/
|
||||
async function createLabel(
|
||||
userIdentifier: string,
|
||||
groupId: string,
|
||||
label: string,
|
||||
): Promise<any> {
|
||||
async function createLabel(userIdentifier: string, groupId: string, label: string): Promise<any> {
|
||||
const query = `
|
||||
INSERT INTO npwd_messages_labels
|
||||
(user_identifier, group_id, label)
|
||||
@@ -166,11 +148,7 @@ async function createMessageGroup(
|
||||
(user_identifier, group_id, participant_identifier)
|
||||
VALUES (?, ?, ?)
|
||||
`;
|
||||
const [results] = await pool.query(query, [
|
||||
userIdentifier,
|
||||
groupId,
|
||||
participantIdentifier,
|
||||
]);
|
||||
const [results] = await pool.query(query, [userIdentifier, groupId, participantIdentifier]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,36 +203,28 @@ async function getMessageCountByGroup(groupId: string): Promise<number> {
|
||||
* groups into a single MessageGroup object.
|
||||
* @param userIdentifier - the user identifier to get message groups for
|
||||
*/
|
||||
async function getConsolidatedMessageGroups(
|
||||
userIdentifier: string,
|
||||
): Promise<MessageGroupMapping> {
|
||||
async function getConsolidatedMessageGroups(userIdentifier: string): Promise<MessageGroupMapping> {
|
||||
const messageGroups = await getMessageGroups(userIdentifier);
|
||||
return messageGroups.reduce(
|
||||
(mapping: MessageGroupMapping, messageGroup: UnformattedMessageGroup) => {
|
||||
const groupId = messageGroup.group_id;
|
||||
const displayTerm = messageGroup.display || messageGroup.phone_number || '???';
|
||||
return messageGroups.reduce((mapping: MessageGroupMapping, messageGroup: UnformattedMessageGroup) => {
|
||||
const groupId = messageGroup.group_id;
|
||||
const displayTerm = messageGroup.display || messageGroup.phone_number || '???';
|
||||
|
||||
if (groupId in mapping) {
|
||||
mapping[groupId].participants = mapping[groupId].participants.concat(displayTerm);
|
||||
} else {
|
||||
mapping[groupId] = {
|
||||
user_identifier: messageGroup.user_identifier,
|
||||
avatar: messageGroup.avatar,
|
||||
label: messageGroup.label,
|
||||
participants: [displayTerm],
|
||||
updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
|
||||
};
|
||||
}
|
||||
return mapping;
|
||||
},
|
||||
{},
|
||||
);
|
||||
if (groupId in mapping) {
|
||||
mapping[groupId].participants = mapping[groupId].participants.concat(displayTerm);
|
||||
} else {
|
||||
mapping[groupId] = {
|
||||
user_identifier: messageGroup.user_identifier,
|
||||
avatar: messageGroup.avatar,
|
||||
label: messageGroup.label,
|
||||
participants: [displayTerm],
|
||||
updatedAt: messageGroup.updatedAt ? messageGroup.updatedAt.toString() : null,
|
||||
};
|
||||
}
|
||||
return mapping;
|
||||
}, {});
|
||||
}
|
||||
|
||||
async function getGroupIds(
|
||||
userIdentifier: string,
|
||||
groupMapping: MessageGroupMapping,
|
||||
): Promise<string[]> {
|
||||
async function getGroupIds(userIdentifier: string, groupMapping: MessageGroupMapping): Promise<string[]> {
|
||||
const groupIds: string[] = [];
|
||||
for (const groupId of Object.keys(groupMapping)) {
|
||||
const isMine = groupMapping[groupId].user_identifier === userIdentifier;
|
||||
@@ -270,9 +240,7 @@ async function getGroupIds(
|
||||
* of MessageGroup objects ready for the UI to consume
|
||||
* @param userIdentifier - user to generate the MessageGroups for
|
||||
*/
|
||||
async function getFormattedMessageGroups(
|
||||
userIdentifier: string,
|
||||
): Promise<MessageGroup[]> {
|
||||
async function getFormattedMessageGroups(userIdentifier: string): Promise<MessageGroup[]> {
|
||||
const groupMapping = await getConsolidatedMessageGroups(userIdentifier);
|
||||
const groupIds = await getGroupIds(userIdentifier, groupMapping);
|
||||
|
||||
@@ -352,9 +320,7 @@ async function createMessageGroupsFromPhoneNumbers(
|
||||
// create a row that contains ourselves so reverse accessing from
|
||||
// other players works as expected
|
||||
createMessageGroup(userIdentifier, groupId, userIdentifier),
|
||||
...identifiers.map((identifier) =>
|
||||
createMessageGroup(userIdentifier, groupId, identifier),
|
||||
),
|
||||
...identifiers.map((identifier) => createMessageGroup(userIdentifier, groupId, identifier)),
|
||||
];
|
||||
|
||||
// we allow users to attach labels to name their group chats
|
||||
@@ -386,60 +352,53 @@ onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
|
||||
}
|
||||
});
|
||||
|
||||
onNet(
|
||||
events.MESSAGES_CREATE_MESSAGE_GROUP,
|
||||
async (phoneNumbers: string[], label: string = null) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = await getIdentifier(_source);
|
||||
const result = await createMessageGroupsFromPhoneNumbers(
|
||||
_identifier,
|
||||
phoneNumbers,
|
||||
label,
|
||||
);
|
||||
onNet(events.MESSAGES_CREATE_MESSAGE_GROUP, async (phoneNumbers: string[], label: string = null) => {
|
||||
const _source = getSource();
|
||||
try {
|
||||
const _identifier = await getIdentifier(_source);
|
||||
const result = await createMessageGroupsFromPhoneNumbers(_identifier, phoneNumbers, label);
|
||||
|
||||
if (result.error && result.duplicate) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_DUPLICATE',
|
||||
type: 'error',
|
||||
});
|
||||
if (result.error && result.duplicate) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_DUPLICATE',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
// if the phoneNumber is invalid
|
||||
} else if (result.error && result.phoneNumber) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_INVALID_PHONE_NUMBER',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
// if you are try to add yourself
|
||||
} else if (result.error && result.mine) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_CREATE_MINE',
|
||||
type: 'error',
|
||||
});
|
||||
} else if (result.error) {
|
||||
// if it just fails, welp
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source, result);
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: `MESSAGES_MESSAGE_GROUP_CREATE_FAILED:`,
|
||||
type: 'error',
|
||||
});
|
||||
} else {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, _source, result);
|
||||
}
|
||||
} catch (e) {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source);
|
||||
// if the phoneNumber is invalid
|
||||
} else if (result.error && result.phoneNumber) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_INVALID_PHONE_NUMBER',
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
// if you are try to add yourself
|
||||
} else if (result.error && result.mine) {
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: 'MESSAGES_MESSAGE_GROUP_CREATE_MINE',
|
||||
type: 'error',
|
||||
});
|
||||
} else if (result.error) {
|
||||
// if it just fails, welp
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source, result);
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: `MESSAGES_MESSAGE_GROUP_CREATE_FAILED:`,
|
||||
type: 'error',
|
||||
});
|
||||
messageLogger.error(`Failed to create message group, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
} else {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS, _source, result);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, _source);
|
||||
|
||||
emitNet(events.MESSAGES_ACTION_RESULT, _source, {
|
||||
message: `MESSAGES_MESSAGE_GROUP_CREATE_FAILED:`,
|
||||
type: 'error',
|
||||
});
|
||||
messageLogger.error(`Failed to create message group, ${e.message}`, {
|
||||
source: _source,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onNet(events.MESSAGES_FETCH_MESSAGES, async (groupId: string) => {
|
||||
const _source = getSource();
|
||||
|
||||
@@ -23,8 +23,7 @@ async function deleteNote(noteId: number, identifier: string) {
|
||||
}
|
||||
|
||||
async function updateNote(note: Note, identifier: string): Promise<any> {
|
||||
const query =
|
||||
'UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?';
|
||||
const query = 'UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?';
|
||||
await pool.query(query, [note.title, note.content, note.id, identifier]);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ async function uploadPhoto(identifier: string, image: string) {
|
||||
}
|
||||
|
||||
async function getPhotosByIdentifier(identifier: string): Promise<IPhoto[]> {
|
||||
const query =
|
||||
'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
|
||||
const query = 'SELECT id, image FROM npwd_phone_gallery WHERE identifier = ? ORDER BY id DESC';
|
||||
const [results] = await pool.query(query, [identifier]);
|
||||
const photos = <IPhoto[]>results;
|
||||
return photos;
|
||||
|
||||
@@ -17,22 +17,10 @@ async function fetchAllListings(): Promise<MarketplaceListing[]> {
|
||||
return listings;
|
||||
}
|
||||
|
||||
async function addListing(
|
||||
identifier: string,
|
||||
name: string,
|
||||
number: any,
|
||||
listing: MarketplaceListing,
|
||||
): Promise<void> {
|
||||
async function addListing(identifier: string, name: string, number: any, listing: MarketplaceListing): Promise<void> {
|
||||
const query =
|
||||
'INSERT INTO npwd_sellout_listings (identifier, name, number, title, url, description) VALUES (?, ?, ?, ?, ?, ?)';
|
||||
await pool.query(query, [
|
||||
identifier,
|
||||
name,
|
||||
number,
|
||||
listing.title,
|
||||
listing.url,
|
||||
listing.description,
|
||||
]);
|
||||
await pool.query(query, [identifier, name, number, listing.title, listing.url, listing.description]);
|
||||
}
|
||||
|
||||
onNet(events.SELLOUT_FETCH_LISTING, async () => {
|
||||
|
||||
@@ -49,10 +49,7 @@ async function fetchAllTweets(profileId: number): Promise<Tweet[]> {
|
||||
* @param profileId - twitter profile id of the player
|
||||
* @param searchValue - value to search
|
||||
*/
|
||||
async function fetchTweetsFiltered(
|
||||
profileId: number,
|
||||
searchValue: string,
|
||||
): Promise<Tweet[]> {
|
||||
async function fetchTweetsFiltered(profileId: number, searchValue: string): Promise<Tweet[]> {
|
||||
const parameterizedSearchValue = `%${searchValue}%`;
|
||||
const query = `
|
||||
SELECT
|
||||
@@ -71,12 +68,7 @@ async function fetchTweetsFiltered(
|
||||
ORDER BY npwd_twitter_tweets.createdAt DESC
|
||||
LIMIT 100
|
||||
`;
|
||||
const [results] = await pool.query(query, [
|
||||
profileId,
|
||||
profileId,
|
||||
parameterizedSearchValue,
|
||||
parameterizedSearchValue,
|
||||
]);
|
||||
const [results] = await pool.query(query, [profileId, profileId, parameterizedSearchValue, parameterizedSearchValue]);
|
||||
const tweets = <Tweet[]>results;
|
||||
return tweets.map((tweet) => ({
|
||||
...tweet,
|
||||
|
||||
Reference in new issue
Block a user