mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
16 files changed
+382
-142
No files matched your search
@@ -15,6 +15,7 @@ import ControlButtons from './buttons/ControlButtons';
|
||||
import IconButtons from './buttons/IconButtons';
|
||||
import { usePhone } from '../../../os/phone/hooks/usePhone';
|
||||
import { getNewLineCount } from '../utils/message';
|
||||
import { NewTweet } from '../../../common/typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -104,11 +105,10 @@ export const AddTweetModal = () => {
|
||||
if (cleanedMessage.length === 0) return;
|
||||
if (!isValidMessage(cleanedMessage)) return;
|
||||
|
||||
const data = {
|
||||
const data: NewTweet = {
|
||||
message,
|
||||
images:
|
||||
images && images.length > 0 ? images.map((image) => image.link).join(IMAGE_DELIMITER) : '',
|
||||
realUser: 'testUser',
|
||||
};
|
||||
Nui.send('phone:createTweet', data);
|
||||
_handleClose();
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'emoji-mart/css/emoji-mart.css';
|
||||
import { useProfile } from '../hooks/useProfile';
|
||||
import ProfilePrompt from './profile/ProfilePrompt';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import { TwitterThemeProvider } from '../providers/TwitterThemeProvider';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
backgroundModal: {
|
||||
@@ -66,26 +67,28 @@ export const TwitterApp = () => {
|
||||
const showTweetButton = !promptProfileName && activePage === 0;
|
||||
|
||||
return (
|
||||
<AppWrapper id="twitter-app">
|
||||
<AddTweetModal />
|
||||
<div className={modalVisible ? classes.backgroundModal : undefined} />
|
||||
<TwitterTitle />
|
||||
<AppContent>
|
||||
{promptProfileName ? (
|
||||
<ProfilePrompt />
|
||||
) : (
|
||||
<Switch>
|
||||
<Route path="/twitter" exact component={TweetListContainer} />
|
||||
<Route path="/twitter/search" component={TwitterSearch} />
|
||||
<Route path="/twitter/profile" component={TwitterProfile} />
|
||||
</Switch>
|
||||
<TwitterThemeProvider>
|
||||
<AppWrapper id="twitter-app">
|
||||
<AddTweetModal />
|
||||
<div className={modalVisible ? classes.backgroundModal : undefined} />
|
||||
<TwitterTitle />
|
||||
<AppContent>
|
||||
{promptProfileName ? (
|
||||
<ProfilePrompt />
|
||||
) : (
|
||||
<Switch>
|
||||
<Route path="/twitter" exact component={TweetListContainer} />
|
||||
<Route path="/twitter/search" component={TwitterSearch} />
|
||||
<Route path="/twitter/profile" component={TwitterProfile} />
|
||||
</Switch>
|
||||
)}
|
||||
</AppContent>
|
||||
{showTweetButton && <TweetButton openModal={openModal} />}
|
||||
{!promptProfileName && (
|
||||
<BottomNavigation activePage={activePage} handleChange={handlePageChange} />
|
||||
)}
|
||||
</AppContent>
|
||||
{showTweetButton && <TweetButton openModal={openModal} />}
|
||||
{!promptProfileName && (
|
||||
<BottomNavigation activePage={activePage} handleChange={handlePageChange} />
|
||||
)}
|
||||
</AppWrapper>
|
||||
</AppWrapper>
|
||||
</TwitterThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import React from 'react';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { Button } from '@material-ui/core';
|
||||
import QuoteIcon from '@material-ui/icons/FormatQuote';
|
||||
|
||||
import { twitterState } from '../../hooks/state';
|
||||
|
||||
export const QuoteButton = ({ message }) => {
|
||||
const setModalVisible = useSetRecoilState(twitterState.showCreateTweetModal);
|
||||
const setMessage = useSetRecoilState(twitterState.modalMessage);
|
||||
|
||||
const handleClick = () => {
|
||||
setMessage(`> ${message}
|
||||
|
||||
`);
|
||||
setModalVisible(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick}>
|
||||
<QuoteIcon />
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default QuoteButton;
|
||||
@@ -0,0 +1,65 @@
|
||||
import React, { useState } from 'react';
|
||||
import { CircularProgress, makeStyles, Button } from '@material-ui/core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { ITwitterTheme } from '../../twitter.theme';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
interface IProps {
|
||||
tweetId: number;
|
||||
retweetId: string;
|
||||
isRetweet: boolean | number;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: ITwitterTheme) => ({
|
||||
icon: {}, // no styles on default icon
|
||||
iconFilled: {
|
||||
color: theme.palette.twitter.main,
|
||||
}
|
||||
}));
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
|
||||
const [retweeted, setRetweeted] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const classes = useStyles();
|
||||
|
||||
const handleClick = () => {
|
||||
// don't allow someone to spam retweet
|
||||
// note that this is enforced by the server currently, not the UI
|
||||
// so if a player refreshes the page they won't see the filled
|
||||
// button anymore
|
||||
if (retweeted) return;
|
||||
|
||||
// if someone is retweeting something that is itself a retweet
|
||||
// then we want to retweet the original post (if we haven't already)
|
||||
const idToRetweet = isRetweet ? retweetId : tweetId;
|
||||
Nui.send('phone:retweet', idToRetweet);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setRetweeted(true);
|
||||
setLoading(false);
|
||||
}, LOADING_TIME);
|
||||
};
|
||||
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Button disabled>
|
||||
<CircularProgress size={22} />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
const className = retweeted ? classes.iconFilled : classes.icon;
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick}>
|
||||
<FontAwesomeIcon icon={faRetweet} className={className} size="lg" />
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default RetweetButton;
|
||||
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { ITwitterTheme } from '../../twitter.theme';
|
||||
|
||||
interface IProps {
|
||||
profileName: string;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: ITwitterTheme) => ({
|
||||
root: {
|
||||
color: theme.palette.secondary.main,
|
||||
fontSize: '16px',
|
||||
justifyContent: 'flex-start',
|
||||
width: '100%',
|
||||
paddingBottom: '8px',
|
||||
marginBottom: '6px',
|
||||
marginTop: '-6px'
|
||||
},
|
||||
}));
|
||||
|
||||
function Retweet({ profileName }: IProps) {
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<FontAwesomeIcon icon={faRetweet} /> {profileName} {t('APPS_TWITTER_RETWEETED')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Retweet;
|
||||
@@ -1,25 +1,33 @@
|
||||
import React, { memo } from 'react';
|
||||
import DOMPurify from 'dompurify';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { ListItemAvatar, Avatar as MuiAvatar, ListItem, Typography } from '@material-ui/core';
|
||||
|
||||
import { Tweet as ITweet } from '../../../../common/typings/twitter';
|
||||
import { secondsToHumanReadable } from '../../utils/time';
|
||||
import LikeButton from '../buttons/LikeButton';
|
||||
import ReplyButton from '../buttons/ReplyButton';
|
||||
import ImageDisplay from '../images/ImageDisplay';
|
||||
import Avatar from '../Avatar';
|
||||
import ShowMore from './ShowMore';
|
||||
import { QuoteButton } from '../buttons/QuoteButton';
|
||||
import { RetweetButton } from '../buttons/RetweetButton';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import DOMPurify from 'dompurify';
|
||||
import Retweet from './Retweet';
|
||||
import ShowMore from './ShowMore';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
overflowX: 'hidden',
|
||||
display: 'flex',
|
||||
flexFlow: 'column nowrap',
|
||||
width: '100%',
|
||||
marginTop: '6px',
|
||||
},
|
||||
container: {
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
alignItems: 'flex-start',
|
||||
width: '100%',
|
||||
marginTop: '6px',
|
||||
},
|
||||
content: {
|
||||
display: 'flex',
|
||||
@@ -53,19 +61,24 @@ const useStyles = makeStyles(() => ({
|
||||
marginLeft: '-20px', // easier to do this here than override the MUI styles
|
||||
marginTop: '3px',
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
export const Tweet = (tweet) => {
|
||||
export const Tweet = (tweet: ITweet) => {
|
||||
const {
|
||||
id,
|
||||
message,
|
||||
images,
|
||||
avatar_url,
|
||||
profile_name,
|
||||
retweetProfileName,
|
||||
retweetAvatarUrl,
|
||||
retweetId,
|
||||
seconds_since_tweet,
|
||||
isLiked,
|
||||
isMine,
|
||||
isReported,
|
||||
isRetweet,
|
||||
isRetweetedByPlayer,
|
||||
} = tweet;
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
@@ -86,41 +99,52 @@ export const Tweet = (tweet) => {
|
||||
ALLOWED_TAGS: ['br'],
|
||||
});
|
||||
|
||||
const profileName = profile_name ? `@${profile_name}` : '';
|
||||
const profileName = isRetweet ? retweetProfileName : profile_name;
|
||||
const formattedProfileName = profileName ? `@${profileName}` : '';
|
||||
|
||||
const avatarUrl = isRetweet ? retweetAvatarUrl : avatar_url;
|
||||
|
||||
return (
|
||||
<ListItem className={classes.root} divider>
|
||||
{enableAvatars && (
|
||||
<ListItemAvatar>
|
||||
<MuiAvatar>
|
||||
<Avatar avatarUrl={avatar_url} height="40px" width="40px" />
|
||||
</MuiAvatar>
|
||||
</ListItemAvatar>
|
||||
)}
|
||||
<div className={classes.content}>
|
||||
<div className={classes.primary}>
|
||||
<div className={classes.profile}>{profileName}</div>
|
||||
<Typography
|
||||
className={classes.date}
|
||||
component="div"
|
||||
variant="body2"
|
||||
color="textSecondary"
|
||||
>
|
||||
{secondsToHumanReadable(t, seconds_since_tweet)}
|
||||
</Typography>
|
||||
</div>
|
||||
<div
|
||||
className={classes.message}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: sanitizedMessage,
|
||||
}}
|
||||
/>
|
||||
{enableImages && <ImageDisplay visible images={images} small />}
|
||||
<div className={classes.buttonContainer}>
|
||||
<ReplyButton profile_name={profile_name} />
|
||||
<LikeButton tweetId={id} isLiked={isLiked} />
|
||||
<QuoteButton message={message} />
|
||||
<ShowMore isMine={isMine} isReported={isReported} id={id} />
|
||||
{isRetweet && <Retweet profileName={profile_name} />}
|
||||
<div className={classes.container}>
|
||||
{enableAvatars && (
|
||||
<ListItemAvatar>
|
||||
<MuiAvatar>
|
||||
<Avatar avatarUrl={avatarUrl} height="40px" width="40px" />
|
||||
</MuiAvatar>
|
||||
</ListItemAvatar>
|
||||
)}
|
||||
<div className={classes.content}>
|
||||
<div className={classes.primary}>
|
||||
<div className={classes.profile}>{formattedProfileName}</div>
|
||||
<Typography
|
||||
className={classes.date}
|
||||
component="div"
|
||||
variant="body2"
|
||||
color="textSecondary"
|
||||
>
|
||||
{secondsToHumanReadable(t, seconds_since_tweet)}
|
||||
</Typography>
|
||||
</div>
|
||||
<div
|
||||
className={classes.message}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: sanitizedMessage,
|
||||
}}
|
||||
/>
|
||||
{enableImages && <ImageDisplay visible images={images} small />}
|
||||
<div className={classes.buttonContainer}>
|
||||
<ReplyButton profile_name={profile_name} />
|
||||
<LikeButton tweetId={id} isLiked={isLiked} />
|
||||
{!isMine && (
|
||||
<RetweetButton
|
||||
tweetId={id}
|
||||
retweetId={retweetId}
|
||||
isRetweet={isRetweet}
|
||||
/>)}
|
||||
<ShowMore isMine={isMine} isReported={isReported} id={id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListItem>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { Tweet } from '../../../common/typings/twitter';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { useNotifications } from '../../../os/notifications/hooks/useNotifications';
|
||||
import { twitterState } from './state';
|
||||
@@ -22,12 +23,15 @@ export const useTwitterNotifications = () => {
|
||||
|
||||
const [unreadCount, setUnreadCount] = useRecoilState(twitterState.unreadTweetsCount);
|
||||
|
||||
const setNotification = ({ profile_name, message }) => {
|
||||
const setNotification = ({ profile_name, message, isRetweet }) => {
|
||||
const titleStr = isRetweet
|
||||
? 'APPS_TWITTER_NEW_RETWEET_BROADCAST'
|
||||
: 'APPS_TWITTER_NEW_BROADCAST';
|
||||
const notification = {
|
||||
app: 'TWITTER',
|
||||
id: NOTIFICATION_ID,
|
||||
sound: true,
|
||||
title: t('APPS_TWITTER_NEW_BROADCAST', { profile_name }),
|
||||
title: t(titleStr, { profile_name }),
|
||||
onClick: () => history.push('/twitter'),
|
||||
content: message,
|
||||
icon,
|
||||
|
||||
@@ -64,4 +64,5 @@ export const useTwitterService = () => {
|
||||
useNuiEvent(APP_TWITTER, 'createTweetLoading', setCreateLoading);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetResult', handleAddAlert);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', setNotification);
|
||||
useNuiEvent(APP_TWITTER, 'phone:retweetExists', handleAddAlert)
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
|
||||
|
||||
import twitterTheme from '../twitter.theme';
|
||||
|
||||
export const TwitterThemeProvider = createAppThemeProvider(twitterTheme);
|
||||
@@ -0,0 +1,28 @@
|
||||
import { blue, common } from '@material-ui/core/colors';
|
||||
|
||||
export const CONTACTS_APP_PRIMARY_COLOR = blue[500];
|
||||
export const CONTACTS_APP_TEXT_COLOR = common.white;
|
||||
|
||||
export interface ITwitterTheme {
|
||||
palette: {
|
||||
twitter: {
|
||||
main: string;
|
||||
},
|
||||
secondary: {
|
||||
main: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const theme: ITwitterTheme = {
|
||||
palette: {
|
||||
twitter: {
|
||||
main: "#00acee",
|
||||
},
|
||||
secondary: {
|
||||
main: '#999',
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default theme;
|
||||
Reference in new issue
Block a user