mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Merge branch 'master' into feature/sticky-notes
This commit is contained in:
22 files changed
+466
-107
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
Button,
|
||||
CircularProgress,
|
||||
MenuItem
|
||||
} from "@material-ui/core";
|
||||
import DoneIcon from '@material-ui/icons/Done';
|
||||
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
function ReportButton({ handleClose, tweetId, isReported }) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send("phone:reportTweet", tweetId);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setLoading(false);
|
||||
handleClose();
|
||||
}, LOADING_TIME);
|
||||
};
|
||||
|
||||
if (isReported) {
|
||||
return (
|
||||
<MenuItem onClick={handleClose}>
|
||||
<DoneIcon />
|
||||
<span style={{ marginLeft: '5px' }}>{t('APPS_TWITTER_REPORTED')}</span>
|
||||
</MenuItem >
|
||||
);
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<Button disabled>
|
||||
<CircularProgress id="twitter-report-progress" size={22} />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<MenuItem onClick={handleClick}>{t('APPS_TWITTER_REPORT')}</MenuItem >
|
||||
);
|
||||
}
|
||||
|
||||
export default ReportButton;
|
||||
@@ -0,0 +1,92 @@
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
Button,
|
||||
Menu,
|
||||
MenuItem
|
||||
} from "@material-ui/core";
|
||||
import MoreIcon from "@material-ui/icons/MoreVert";
|
||||
import { usePhone } from "../../../../os/phone/hooks/usePhone";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
import ReportButton from '../buttons/ReportButton';
|
||||
import { Tweet } from "./Tweet";
|
||||
|
||||
|
||||
/**
|
||||
* Ok this is some bullshit. Due to either scaling issues or the NUI
|
||||
* overlay being different than the display resolution just letting
|
||||
* material-ui determine what the anchor positioning of the popover
|
||||
* is not reliable and has some error that appears to scale vertically.
|
||||
*
|
||||
* This vertical offset raises the popover positioning implementing the
|
||||
* transformOrigin prop that material-ui's Popover element provides.
|
||||
*
|
||||
* These coefficients are NOT based on any known offsets or calc()
|
||||
* functions. They are empiricallly determined. The actual scaling issue
|
||||
* does NOT appear to be linear, but over the comparatively low height
|
||||
* of the phone compared to the window it produces results that are within
|
||||
* acceptable tolerances from the player's perspective.
|
||||
* @param top - the computed distance from the top of the window to the top
|
||||
* of the anchor element
|
||||
*/
|
||||
function calculateVerticalOffset(top: number): number {
|
||||
return top * 0.20 - 38;
|
||||
}
|
||||
|
||||
export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
||||
const [verticalOffset, setVerticalOffset] = useState(0);
|
||||
const { t } = useTranslation();
|
||||
const { config } = usePhone();
|
||||
|
||||
if (!config) return null;
|
||||
|
||||
const handleClick = (event: React.MouseEvent) => {
|
||||
const element = event.currentTarget
|
||||
setAnchorEl(element);
|
||||
|
||||
const top = window.pageYOffset + element.getBoundingClientRect().top
|
||||
setVerticalOffset(calculateVerticalOffset(top));
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setAnchorEl(null);
|
||||
setVerticalOffset(0);
|
||||
};
|
||||
|
||||
const handleDeleteTweet = () => {
|
||||
Nui.send("phone:deleteTweet", id);
|
||||
handleClose();
|
||||
}
|
||||
|
||||
const allowedToDelete = config.twitter.allowDeleteTweets && isMine;
|
||||
const allowedToReport = config.twitter.allowReportTweets && !isMine;
|
||||
|
||||
// if the user cannot perform any actions in show more then don't
|
||||
// allow them to interact with it
|
||||
let _handleClick = allowedToDelete || allowedToReport ? handleClick : () => null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button aria-controls="simple-menu" aria-haspopup="true" onClick={_handleClick} >
|
||||
<MoreIcon />
|
||||
</Button>
|
||||
<Menu
|
||||
id="simple-menu"
|
||||
anchorEl={anchorEl}
|
||||
keepMounted
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={handleClose}
|
||||
transformOrigin={{
|
||||
vertical: verticalOffset,
|
||||
horizontal: 'left'
|
||||
}}
|
||||
>
|
||||
{allowedToDelete && <MenuItem onClick={handleDeleteTweet}>{t('APPS_TWITTER_DELETE')}</MenuItem >}
|
||||
{allowedToReport && <ReportButton handleClose={handleClose} isReported={isReported} tweetId={id}/>}
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowMore;
|
||||
@@ -1,22 +1,27 @@
|
||||
import React from "react";
|
||||
import React, { useState, memo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import {
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar,
|
||||
Button,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
Paper,
|
||||
Typography,
|
||||
} from "@material-ui/core";
|
||||
import MoreIcon from "@material-ui/icons/MoreVert";
|
||||
|
||||
import { ListItem } from "../../../../ui/components/ListItem";
|
||||
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 { usePhone } from "../../../../os/phone/hooks/usePhone";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
@@ -58,7 +63,7 @@ const useStyles = makeStyles(() => ({
|
||||
width: "100%",
|
||||
marginLeft: "-20px", // easier to do this here than override the MUI styles
|
||||
marginTop: "3px",
|
||||
},
|
||||
}
|
||||
}));
|
||||
|
||||
export const Tweet = (tweet) => {
|
||||
@@ -70,6 +75,8 @@ export const Tweet = (tweet) => {
|
||||
profile_name,
|
||||
seconds_since_tweet,
|
||||
isLiked,
|
||||
isMine,
|
||||
isReported,
|
||||
} = tweet;
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
@@ -81,7 +88,6 @@ export const Tweet = (tweet) => {
|
||||
// this is a workaround to transfer string new lines and returns that
|
||||
// are stored into the database into html for the UI to render
|
||||
const formattedMessage = message.replace(/\n\r?/g, "<br />");
|
||||
|
||||
const profileName = profile_name ? `@${profile_name}` : "";
|
||||
|
||||
return (
|
||||
@@ -114,13 +120,11 @@ export const Tweet = (tweet) => {
|
||||
<ReplyButton profile_name={profile_name} />
|
||||
<LikeButton tweetId={id} isLiked={isLiked} />
|
||||
<QuoteButton message={message} />
|
||||
<Button>
|
||||
<MoreIcon />
|
||||
</Button>
|
||||
<ShowMore isMine={isMine} isReported={isReported} id={id} />
|
||||
</div>
|
||||
</div>
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
|
||||
export default Tweet;
|
||||
export default memo(Tweet);
|
||||
@@ -30,6 +30,11 @@ some of the Material UI primary theme settings */
|
||||
color: #00acee !important;
|
||||
}
|
||||
|
||||
/* override circular progress on the report button */
|
||||
#twitter-report-progress {
|
||||
color: #00acee !important;
|
||||
}
|
||||
|
||||
/*
|
||||
override position of the snackbar so that it appears
|
||||
within the phone rather than on the game UI */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useRecoilValue } from "recoil";
|
||||
import { Tweet } from "../interfaces";
|
||||
|
||||
import { Tweet } from "../../../common/interfaces/twitter";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
interface ITwitterNotification {
|
||||
|
||||
Whitespace-only changes.
@@ -10,7 +10,7 @@ export const IMAGE_DELIMITER = "||!||";
|
||||
* @param {string} link - a URL we are trying to validate
|
||||
* @param {func} onSuccess - callback if the link is valid
|
||||
*/
|
||||
export function withValidImage(link, onSuccess) {
|
||||
export function withValidImage(link: string, onSuccess: any): void {
|
||||
const image = new Image();
|
||||
image.onload = onSuccess;
|
||||
image.onerror = () => {
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
interface TwitterConfig {
|
||||
showNotifications: boolean;
|
||||
generateProfileNameFromUsers: boolean;
|
||||
allowEdtiableProfileName: boolean;
|
||||
characterLimit: number;
|
||||
enableAvatars: boolean;
|
||||
enableEmojis: boolean;
|
||||
enableImages: boolean;
|
||||
maxImages: number;
|
||||
}
|
||||
|
||||
interface NotificationConfig {
|
||||
horizontal: "left" | "center" | "right";
|
||||
vertical: "bottom" | "top";
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
Locale: string;
|
||||
KeyTogglePhone: number;
|
||||
KeyTakeCall: number;
|
||||
PhoneAsItem: boolean;
|
||||
SwimDestroy: boolean;
|
||||
RunRate: number;
|
||||
DestoryChance: number;
|
||||
DestroyPhoneReCheck: number;
|
||||
twitter: TwitterConfig;
|
||||
notificationPosition: NotificationConfig;
|
||||
}
|
||||
|
||||
showNotifications: boolean;
|
||||
generateProfileNameFromUsers: boolean;
|
||||
allowEdtiableProfileName: boolean;
|
||||
allowDeleteTweets: boolean;
|
||||
allowReportTweets: boolean;
|
||||
characterLimit: number;
|
||||
enableAvatars: boolean;
|
||||
enableEmojis: boolean;
|
||||
enableImages: boolean;
|
||||
maxImages: number;
|
||||
}
|
||||
|
||||
interface NotificationConfig {
|
||||
horizontal: "left" | "center" | "right";
|
||||
vertical: "bottom" | "top";
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
Locale: string;
|
||||
KeyTogglePhone: number;
|
||||
KeyTakeCall: number;
|
||||
PhoneAsItem: boolean;
|
||||
SwimDestroy: boolean;
|
||||
RunRate: number;
|
||||
DestoryChance: number;
|
||||
DestroyPhoneReCheck: number;
|
||||
twitter: TwitterConfig;
|
||||
notificationPosition: NotificationConfig;
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
|
||||
export interface Tweet {
|
||||
id: number;
|
||||
profile_name?: string;
|
||||
profile_id: number;
|
||||
avatar_url?: string;
|
||||
message: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
images?: string;
|
||||
likes?: number;
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
id: number;
|
||||
profile_name: string;
|
||||
identifier: string;
|
||||
avatar_url?: string;
|
||||
bio?: string;
|
||||
location?: string;
|
||||
job?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
id: number;
|
||||
profile_name?: string;
|
||||
profile_id: number;
|
||||
isMine: boolean;
|
||||
isReported: boolean;
|
||||
avatar_url?: string;
|
||||
message: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
images?: string;
|
||||
likes?: number;
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
id: number;
|
||||
profile_name: string;
|
||||
identifier: string;
|
||||
avatar_url?: string;
|
||||
bio?: string;
|
||||
location?: string;
|
||||
job?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -18,6 +18,9 @@
|
||||
"APPS_TWITTER_SUBMIT_IMAGE": "Add Media",
|
||||
"APPS_TWITTER_CLOSE_IMAGE": "Close",
|
||||
"APPS_TWITTER_CLOSE": "Close",
|
||||
"APPS_TWITTER_DELETE": "Delete",
|
||||
"APPS_TWITTER_REPORT": "Report",
|
||||
"APPS_TWITTER_REPORTED": " Reported",
|
||||
"APPS_TWITTER_JUST_NOW": "Just now",
|
||||
"APPS_TWITTER_SEARCH_TWEETS": "Search for tweets",
|
||||
"APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER": "Search by profile name or message",
|
||||
|
||||
@@ -35,7 +35,6 @@ export const GridMenu = ({ items, Component = AppIcon }) => {
|
||||
key={item.id}
|
||||
item
|
||||
className={classes.item}
|
||||
tabIndex="-1"
|
||||
component={Link}
|
||||
to={item.path}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user