printWidth: 100

This commit is contained in:
Christopher committed 2021-03-02 21:03:06 +01:00
1 parent d27aeb3b0e
commit 6f4ee009a9
63 files changed
+602 -223

No files matched your search

+1 -1
View File
@@ -1,5 +1,5 @@
{
"printWidth": 120,
"printWidth": 100,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
+4 -1
View File
@@ -2,7 +2,10 @@
<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/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>
@@ -30,9 +30,21 @@ 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,20 +33,22 @@ 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>
{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>
<div>
<p className={TransactionTypes[transaction.type]}>
{transaction.type === 'Withdraw' ? '-' : '+'}
{transaction.amount}
</p>
</div>
</div>
))}
))}
<TablePagination
rowsPerPageOptions={[3, 5]}
className={classes.pagination}
@@ -18,7 +18,10 @@ 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);
@@ -28,7 +28,9 @@ 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">
@@ -48,7 +48,10 @@ 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,7 +25,11 @@ 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>
</>
@@ -27,7 +27,13 @@ const DialerNavBar = () => {
return (
<BottomNavigation value={page} onChange={handleChange} showLabels className={classes.root}>
<BottomNavigationAction label="History" value="/phone" component={NavLink} icon={<HistoryIcon />} to="/phone" />
<BottomNavigationAction
label="History"
value="/phone"
component={NavLink}
icon={<HistoryIcon />}
to="/phone"
/>
<BottomNavigationAction
label="Dial"
value="/phone/dial"
@@ -68,7 +68,9 @@ export const DialerHistory = ({ calls }) => {
{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>
@@ -86,7 +88,9 @@ export const DialerHistory = ({ calls }) => {
{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,7 +35,9 @@ 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,7 +38,11 @@ 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')} />
@@ -99,7 +99,13 @@ 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>
@@ -18,7 +18,10 @@ const MessagesList = (): any => {
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],
);
@@ -55,7 +58,11 @@ const MessagesList = (): any => {
<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,10 +38,17 @@ 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,7 +41,13 @@ 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>
@@ -77,7 +77,8 @@ export const MessageModal = () => {
const truncatedHeader = `${header.slice(0, MAX_HEADER_CHARS).trim()}...`;
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}>
+4 -3
View File
@@ -14,9 +14,10 @@ export default (): IUseMessages => {
const [messages, setMessages] = useRecoilState<Message[] | null>(messageState.messages);
const messageGroups = useRecoilValue<MessageGroup[] | null>(messageState.messageGroups);
const [createMessageGroupResult, setCreateMessageGroupResult] = useRecoilState<CreateMessageGroupResult | null>(
messageState.createMessageGroupResult,
);
const [
createMessageGroupResult,
setCreateMessageGroupResult,
] = useRecoilState<CreateMessageGroupResult | null>(messageState.createMessageGroupResult);
const clearMessageGroupResult = () => setCreateMessageGroupResult(null);
+10 -1
View File
@@ -1,4 +1,13 @@
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';
@@ -54,7 +54,10 @@ 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,7 +28,11 @@ export const NavigationBar = () => {
showLabels
className={classes.root}
>
<BottomNavigationAction component={Link} icon={<FontAwesomeIcon icon={faHome} />} to="/sellout" />
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faHome} />}
to="/sellout"
/>
<BottomNavigationAction component={Link} icon={<AddCircleIcon />} to="/sellout/new" />
</BottomNavigation>
);
@@ -10,7 +10,15 @@ 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,
@@ -77,11 +85,15 @@ export const SettingsApp = () => {
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();
@@ -90,7 +102,11 @@ 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}
@@ -102,7 +118,10 @@ 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
@@ -126,7 +145,10 @@ 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
@@ -194,7 +216,9 @@ 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,3 +1,4 @@
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,7 +106,8 @@ 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);
@@ -155,10 +156,18 @@ export const AddTweetModal = () => {
return (
<Modal visible={modalVisible} handleClose={_handleClose}>
<TweetMessage modalVisible={modalVisible} message={message} handleChange={handleMessageChange} />
<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}
@@ -82,7 +82,9 @@ export const TwitterApp = () => {
)}
</AppContent>
{showTweetButton && <TweetButton openModal={openModal} />}
{!promptProfileName && <BottomNavigation activePage={activePage} handleChange={handlePageChange} />}
{!promptProfileName && (
<BottomNavigation activePage={activePage} handleChange={handlePageChange} />
)}
</AppWrapper>
);
};
@@ -21,7 +21,9 @@ export const ControlButtons = ({ showImagePrompt, showEmoji, onCloseClick, onPri
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 (
@@ -30,7 +32,12 @@ export const ControlButtons = ({ showImagePrompt, showEmoji, onCloseClick, onPri
{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>
)}
@@ -70,13 +70,22 @@ 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,8 +76,12 @@ 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>
</>
);
@@ -56,7 +56,17 @@ 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();
@@ -90,7 +100,12 @@ 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,10 +51,14 @@ 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;
+3 -1
View File
@@ -19,7 +19,9 @@ 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,7 +4,9 @@ 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,
@@ -6,7 +6,10 @@ 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,
+9 -1
View File
@@ -19,7 +19,15 @@
"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
View File
@@ -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;
+19 -4
View File
@@ -1,7 +1,13 @@
import React from 'react';
import { blue, common, grey, purple } from '@material-ui/core/colors';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAd, faPlaneArrival, faPhoneAlt, 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';
@@ -22,9 +28,18 @@ 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 {
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';
+3 -1
View File
@@ -12,7 +12,9 @@ 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 };
};
@@ -34,7 +34,15 @@ 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;
@@ -29,7 +29,11 @@ export const Navigation = () => {
}}
>
<BottomNavigationAction label="Home" value={() => history.push('/')} icon={<AppsIcon />} />
<BottomNavigationAction label="Close" value={closePhone} icon={<RadioButtonUncheckedIcon />} />
<BottomNavigationAction
label="Close"
value={closePhone}
icon={<RadioButtonUncheckedIcon />}
/>
<BottomNavigationAction
label="Back"
value={() => !isExact && history.goBack()}
@@ -1,5 +1,15 @@
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';
@@ -56,7 +66,13 @@ 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 (
<>
@@ -118,7 +134,11 @@ 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,6 +1,13 @@
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) => ({
@@ -61,7 +61,9 @@ 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(() => {
@@ -154,10 +156,16 @@ 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]]);
+14 -1
View File
@@ -41,7 +41,20 @@ 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) {
+41 -38
View File
@@ -26,47 +26,50 @@ 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 find = soundRefs.current.get(url);
if (find) {
find.howl.volume(volume);
find.howl.loop(loop);
if (autoplay) {
find.howl.play();
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();
}
return res({ howl: find.howl, url });
}
const instance = new Howl({
src: url,
loop,
volume,
autoplay,
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);
});
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) => {
+5 -1
View File
@@ -9,7 +9,11 @@ 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
? {
+12 -2
View File
@@ -23,13 +23,23 @@ 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 -1
View File
@@ -43,7 +43,11 @@ export const AppIcon = ({ id, nameLocale, name, icon, backgroundColor, color, no
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>
+5 -1
View File
@@ -28,7 +28,11 @@ 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 (
+9 -2
View File
@@ -17,7 +17,8 @@ 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}`,
},
@@ -43,5 +44,11 @@ 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}
/>
);
};
+2 -1
View File
@@ -17,7 +17,8 @@ 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}`,
},
+6 -1
View File
@@ -23,5 +23,10 @@ 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,
];
};
+5 -1
View File
@@ -16,7 +16,11 @@ 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;
+20 -17
View File
@@ -35,23 +35,26 @@ 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) => {
+7 -4
View File
@@ -23,10 +23,13 @@ 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);
+17 -1
View File
@@ -24,7 +24,23 @@ 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');
+3 -1
View File
@@ -13,7 +13,9 @@ 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;
}
+3 -1
View File
@@ -14,7 +14,9 @@ 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) => {
+9 -2
View File
@@ -30,7 +30,8 @@ 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]);
}
@@ -95,7 +96,13 @@ 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) {
+17 -4
View File
@@ -24,15 +24,28 @@ async function fetchAllContacts(identifier: string): Promise<Contacts[]> {
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> {
+2 -1
View File
@@ -7,7 +7,8 @@ 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}`;
};
+75 -58
View File
@@ -1,7 +1,11 @@
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';
@@ -42,7 +46,11 @@ 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)
@@ -205,26 +213,32 @@ async function getMessageCountByGroup(groupId: string): Promise<number> {
*/
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;
@@ -352,53 +366,56 @@ 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 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 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);
messageLogger.error(`Failed to create message group, ${e.message}`, {
source: _source,
});
}
} 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();
+14 -2
View File
@@ -17,10 +17,22 @@ 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 () => {
+6 -1
View File
@@ -68,7 +68,12 @@ async function fetchTweetsFiltered(profileId: number, searchValue: string): Prom
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,