styling: Enforced styling across all files (#55)

This commit is contained in:
Taso authored and GitHub committed 2021-01-12 21:31:03 -05:00
1 parent c9b3174505
commit 54daa42454
165 files changed
+1879 -1725

No files matched your search

@@ -1,54 +1,54 @@
import React, { useState, useEffect } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Button } from "@material-ui/core";
import CloseIcon from "@material-ui/icons/Close";
import { v4 as uuidv4 } from "uuid";
import React, { useState, useEffect } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Button } from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import { v4 as uuidv4 } from 'uuid';
import Nui from "../../../os/nui-events/utils/Nui";
import Modal from "../../../ui/components/Modal";
import { IMAGE_DELIMITER } from "../utils/images";
import { withValidImage } from "../utils/images";
import { useModal } from "../hooks/useModal";
import EmojiSelect from "./EmojiSelect";
import ImageDisplay from "./images/ImageDisplay";
import ImagePrompt from "./images/ImagePrompt";
import TweetMessage from "./tweet/TweetMessage";
import ControlButtons from "./buttons/ControlButtons";
import IconButtons from "./buttons/IconButtons";
import { usePhone } from "../../../os/phone/hooks/usePhone";
import Nui from '../../../os/nui-events/utils/Nui';
import Modal from '../../../ui/components/Modal';
import { IMAGE_DELIMITER } from '../utils/images';
import { withValidImage } from '../utils/images';
import { useModal } from '../hooks/useModal';
import EmojiSelect from './EmojiSelect';
import ImageDisplay from './images/ImageDisplay';
import ImagePrompt from './images/ImagePrompt';
import TweetMessage from './tweet/TweetMessage';
import ControlButtons from './buttons/ControlButtons';
import IconButtons from './buttons/IconButtons';
import { usePhone } from '../../../os/phone/hooks/usePhone';
const useStyles = makeStyles((theme) => ({
root: {
zIndex: 10,
background: "#424242",
marginTop: "15px",
width: "90%",
display: "flex",
flexFlow: "column nowrap",
position: "absolute",
top: "80px",
background: '#424242',
marginTop: '15px',
width: '90%',
display: 'flex',
flexFlow: 'column nowrap',
position: 'absolute',
top: '80px',
},
button: {
margin: 5,
marginTop: 20,
},
close: {
position: "absolute",
top: "12px",
right: "4px",
position: 'absolute',
top: '12px',
right: '4px',
zIndex: 2,
},
buttonsContainer: {
paddingBottom: "8px",
display: "flex",
flexFlow: "row nowrap",
justifyContent: "space-between",
flex: "1 0 45px",
paddingBottom: '8px',
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'space-between',
flex: '1 0 45px',
},
emojiPicker: {
background: "none",
border: "none",
boxShadow: "none",
background: 'none',
border: 'none',
boxShadow: 'none',
},
}));
@@ -64,7 +64,7 @@ export const AddTweetModal = () => {
const [showEmoji, setShowEmoji] = useState(false);
const [showImagePrompt, setShowImagePrompt] = useState(false);
const [link, setLink] = useState("");
const [link, setLink] = useState('');
const [images, setImages] = useState<Image[]>([]);
@@ -72,9 +72,9 @@ export const AddTweetModal = () => {
setShowImagePrompt(false);
setShowEmoji(false);
setLink("");
setLink('');
setImages([]);
setMessage("");
setMessage('');
};
const _handleClose = () => {
@@ -84,15 +84,15 @@ export const AddTweetModal = () => {
// when the user presses escape we should close the modal
const _handleEscape = (e) => {
const isEscapeKey = e.key === "Escape" || e.key === "Esc";
const isEscapeKey = e.key === 'Escape' || e.key === 'Esc';
if (isEscapeKey) {
e.preventDefault();
_handleClose();
}
};
useEffect(() => {
window.addEventListener("keydown", _handleEscape, true);
return () => window.removeEventListener("keydown", _handleEscape);
window.addEventListener('keydown', _handleEscape, true);
return () => window.removeEventListener('keydown', _handleEscape);
});
if (!config) return null;
@@ -107,10 +107,10 @@ export const AddTweetModal = () => {
images:
images && images.length > 0
? images.map((image) => image.link).join(IMAGE_DELIMITER)
: "",
realUser: "testUser",
: '',
realUser: 'testUser',
};
Nui.send("phone:createTweet", data);
Nui.send('phone:createTweet', data);
_handleClose();
};
@@ -119,7 +119,7 @@ export const AddTweetModal = () => {
const addImage = () => {
// strip any whitespace from the link in case the user
// added some spaces/returns accidentally
const cleanedLink = link.replace("/ /g", "");
const cleanedLink = link.replace('/ /g', '');
// because we're only storing strings in the database we need
// to give this an arbirtrary (but unique) id so that we can
// correctly filter an array of images when the user wants to
@@ -134,7 +134,7 @@ export const AddTweetModal = () => {
withValidImage(cleanedLink, () => setImages([...images, image]));
setShowImagePrompt(false);
setLink("");
setLink('');
};
const removeImage = (id) =>
setImages(images.filter((image) => id !== image.id));
@@ -161,7 +161,7 @@ export const AddTweetModal = () => {
return (
<Modal visible={modalVisible} handleClose={_handleClose}>
<Button className={classes.close} onClick={_handleClose}>
<CloseIcon color="action" />
<CloseIcon color='action' />
</Button>
<TweetMessage message={message} handleChange={handleMessageChange} />
<ImagePrompt
+12 -12
View File
@@ -1,16 +1,16 @@
import React, { useState } from "react";
import { makeStyles } from "@material-ui/core/styles";
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { usePhone } from "../../../os/phone/hooks/usePhone";
import { IMG_DEFAULT_AVATAR, IMG_INVALID_AVATAR } from "../utils/constants";
import { usePhone } from '../../../os/phone/hooks/usePhone';
import { IMG_DEFAULT_AVATAR, IMG_INVALID_AVATAR } from '../utils/constants';
const useStyles = makeStyles({
root: {
width: "100%",
width: '100%',
},
img: {
borderRadius: "50%",
objectFit: "cover",
borderRadius: '50%',
objectFit: 'cover',
},
});
@@ -30,17 +30,17 @@ function Avatar({ avatarUrl, showInvalidImage, height, width }) {
<img
className={classes.img}
src={showInvalidImage ? IMG_INVALID_AVATAR : IMG_DEFAULT_AVATAR}
alt="Invalid avatar"
alt='Invalid avatar'
style={{ height, width }}
/>
)}
<img
className={classes.img}
src={avatarUrl || IMG_DEFAULT_AVATAR}
alt="Your profile avatar"
alt='Your profile avatar'
onError={handleImageError}
onLoad={handleImageLoad}
style={{ display: showImageError ? "none" : "block", height, width }}
style={{ display: showImageError ? 'none' : 'block', height, width }}
/>
</div>
);
@@ -49,8 +49,8 @@ function Avatar({ avatarUrl, showInvalidImage, height, width }) {
Avatar.defaultProps = {
avatarUrl: null,
showInvalidImage: false,
height: "125px",
width: "125px",
height: '125px',
width: '125px',
};
export default Avatar;
@@ -1,14 +1,14 @@
import React from "react";
import { Link } from "react-router-dom";
import { makeStyles } from "@material-ui/core/styles";
import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
import HomeIcon from "@material-ui/icons/Home";
import SearchIcon from "@material-ui/icons/Search";
import ProfileIcon from "@material-ui/icons/Person";
import React from 'react';
import { Link } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
import HomeIcon from '@material-ui/icons/Home';
import SearchIcon from '@material-ui/icons/Search';
import ProfileIcon from '@material-ui/icons/Person';
const useStyles = makeStyles({
root: {
width: "100%",
width: '100%',
},
});
@@ -23,17 +23,17 @@ export function TwitterBottomNavigation({ activePage, handleChange }) {
>
<BottomNavigationAction
component={Link}
to="/twitter"
to='/twitter'
icon={<HomeIcon />}
/>
<BottomNavigationAction
component={Link}
to="/twitter/search"
to='/twitter/search'
icon={<SearchIcon />}
/>
<BottomNavigationAction
component={Link}
to="/twitter/profile"
to='/twitter/profile'
icon={<ProfileIcon />}
/>
</BottomNavigation>
@@ -1,5 +1,5 @@
import React, { memo } from "react";
import { Picker } from "emoji-mart";
import React, { memo } from 'react';
import { Picker } from 'emoji-mart';
export const EmojiSelect = ({ visible, onEmojiClick }) => {
if (!visible) return null;
@@ -7,8 +7,8 @@ export const EmojiSelect = ({ visible, onEmojiClick }) => {
return (
<Picker
onClick={onEmojiClick}
set="google"
theme="dark"
set='google'
theme='dark'
showPreview={false}
/>
);
@@ -1,30 +1,30 @@
import React, { useState, useEffect } from "react";
import { Switch, Route } from "react-router-dom";
import { makeStyles } from "@material-ui/core/styles";
import React, { useState, useEffect } from 'react';
import { Switch, Route } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import Nui from "../../../os/nui-events/utils/Nui";
import { AppWrapper } from "../../../ui/components";
import { AppContent } from "../../../ui/components/AppContent";
import TweetListContainer from "./tweet/TweetListContainer";
import AddTweetModal from "./AddTweetModal";
import { useModal } from "../hooks/useModal";
import TweetButton from "./buttons/TweetButton";
import TwitterTitle from "./TwitterTitle";
import BottomNavigation from "./BottomNavigation";
import TwitterProfile from "./profile/Profile";
import AlertBar from "./alerts/AlertBar";
import TwitterSearch from "./TwitterSearch";
import Nui from '../../../os/nui-events/utils/Nui';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import TweetListContainer from './tweet/TweetListContainer';
import AddTweetModal from './AddTweetModal';
import { useModal } from '../hooks/useModal';
import TweetButton from './buttons/TweetButton';
import TwitterTitle from './TwitterTitle';
import BottomNavigation from './BottomNavigation';
import TwitterProfile from './profile/Profile';
import AlertBar from './alerts/AlertBar';
import TwitterSearch from './TwitterSearch';
import "./twitter.css";
import "emoji-mart/css/emoji-mart.css";
import { useProfile } from "../hooks/useProfile";
import ProfilePrompt from "./profile/ProfilePrompt";
import './twitter.css';
import 'emoji-mart/css/emoji-mart.css';
import { useProfile } from '../hooks/useProfile';
import ProfilePrompt from './profile/ProfilePrompt';
const useStyles = makeStyles(() => ({
backgroundModal: {
background: "black",
opacity: "0.6",
position: "absolute",
background: 'black',
opacity: '0.6',
position: 'absolute',
top: 0,
left: 0,
right: 0,
@@ -42,7 +42,7 @@ export const TwitterApp = () => {
const { profile } = useProfile();
useEffect(() => {
Nui.send("phone:getOrCreateTwitterProfile", {});
Nui.send('phone:getOrCreateTwitterProfile', {});
// this is a polling implementation. It is possible that
// there is some interaction where, on a new tweet, all
@@ -52,7 +52,7 @@ export const TwitterApp = () => {
// TODO don't call fetchTweets - implement a function that only
// returns tweets that we don't already have
const timeout = window.setTimeout(() => {
Nui.send("phone:fetchTweets", {});
Nui.send('phone:fetchTweets', {});
}, TWEETS_REFRESH_RATE);
return () => window.clearTimeout(timeout);
}, []);
@@ -67,7 +67,7 @@ export const TwitterApp = () => {
const showTweetButton = !promptProfileName && activePage === 0;
return (
<AppWrapper id="twitter-app">
<AppWrapper id='twitter-app'>
<AddTweetModal />
<div className={modalVisible ? classes.backgroundModal : undefined} />
<TwitterTitle />
@@ -76,9 +76,9 @@ export const TwitterApp = () => {
<ProfilePrompt />
) : (
<Switch>
<Route path="/twitter" exact component={TweetListContainer} />
<Route path="/twitter/search" component={TwitterSearch} />
<Route path="/twitter/profile" component={TwitterProfile} />
<Route path='/twitter' exact component={TweetListContainer} />
<Route path='/twitter/search' component={TwitterSearch} />
<Route path='/twitter/profile' component={TwitterProfile} />
</Switch>
)}
</AppContent>
@@ -1,29 +1,29 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
import TweetList from "./tweet/TweetList";
import React, { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { TextField } from '@material-ui/core';
import TweetList from './tweet/TweetList';
import Nui from "../../../os/nui-events/utils/Nui";
import SearchButton from "./buttons/SearchButton";
import { useFilteredTweets } from "../hooks/useFilteredTweets";
import Nui from '../../../os/nui-events/utils/Nui';
import SearchButton from './buttons/SearchButton';
import { useFilteredTweets } from '../hooks/useFilteredTweets';
const useStyles = makeStyles({
root: {
width: "100%",
width: '100%',
},
searchContainer: {
padding: "15px",
padding: '15px',
},
search: {
width: "100%",
width: '100%',
},
});
function TwitterSearch() {
const classes = useStyles();
const { t } = useTranslation();
const [searchValue, setSearchValue] = useState("");
const [searchValue, setSearchValue] = useState('');
const { tweets } = useFilteredTweets();
const handleChange = (e) => setSearchValue(e.target.value);
@@ -32,7 +32,7 @@ function TwitterSearch() {
const cleanedSearchValue = searchValue.trim();
if (!cleanedSearchValue) return;
Nui.send("phone:fetchTweetsFiltered", cleanedSearchValue);
Nui.send('phone:fetchTweetsFiltered', cleanedSearchValue);
};
const filteredTweets = tweets || [];
@@ -43,11 +43,11 @@ function TwitterSearch() {
<div className={classes.searchContainer}>
<TextField
className={classes.search}
placeholder={t("APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER")}
label={t("APPS_TWITTER_SEARCH_TWEETS")}
placeholder={t('APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER')}
label={t('APPS_TWITTER_SEARCH_TWEETS')}
value={searchValue}
onChange={handleChange}
size="medium"
size='medium'
inputRef={(input) => input && input.focus()}
/>
</div>
@@ -1,20 +1,20 @@
import React from "react";
import Paper from "@material-ui/core/Paper";
import { makeStyles } from "@material-ui/core";
import TwitterIcon from "@material-ui/icons/Twitter";
import React from 'react';
import Paper from '@material-ui/core/Paper';
import { makeStyles } from '@material-ui/core';
import TwitterIcon from '@material-ui/icons/Twitter';
const useStyles = makeStyles((theme) => ({
root: {
height: "60px",
width: "100%",
display: "flex",
flexFlow: "row nowrap",
justifyContent: "center",
alignItems: "center",
background: "#424242",
height: '60px',
width: '100%',
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'center',
alignItems: 'center',
background: '#424242',
},
icon: {
color: "#00acee",
color: '#00acee',
fontSize: 30,
},
}));
@@ -22,7 +22,7 @@ const useStyles = makeStyles((theme) => ({
export function TwitterTitle() {
const classes = useStyles();
return (
<Paper elevation={24} variant="outlined" square className={classes.root}>
<Paper elevation={24} variant='outlined' square className={classes.root}>
<TwitterIcon className={classes.icon} />
</Paper>
);
@@ -1,16 +1,16 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Snackbar } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Snackbar } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { useProfile } from "../../hooks/useProfile";
import { useTweetStatus } from "../../hooks/useTweetStatus";
import Alert from "../../../../ui/components/Alert";
import { useProfile } from '../../hooks/useProfile';
import { useTweetStatus } from '../../hooks/useTweetStatus';
import Alert from '../../../../ui/components/Alert';
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
bottom: "60px",
width: '100%',
bottom: '60px',
},
}));
@@ -34,20 +34,20 @@ export default function AlertBar() {
useEffect(() => {
if (createTweetSuccessful === true) {
setOpen(true);
setSeverity("success");
setMessage(t("APPS_TWITTER_CREATE_SUCCESS"));
setSeverity('success');
setMessage(t('APPS_TWITTER_CREATE_SUCCESS'));
} else if (createTweetSuccessful === false) {
setOpen(true);
setSeverity("error");
setMessage(t("APPS_TWITTER_CREATE_FAILED"));
setSeverity('error');
setMessage(t('APPS_TWITTER_CREATE_FAILED'));
} else if (updateProfileSuccessful === true) {
setOpen(true);
setSeverity("success");
setMessage(t("APPS_TWITTER_EDIT_PROFILE_SUCCESS"));
setSeverity('success');
setMessage(t('APPS_TWITTER_EDIT_PROFILE_SUCCESS'));
} else if (updateProfileSuccessful === false) {
setOpen(true);
setSeverity("error");
setMessage(t("APPS_TWITTER_EDIT_PROFILE_FAILURE"));
setSeverity('error');
setMessage(t('APPS_TWITTER_EDIT_PROFILE_FAILURE'));
}
}, [updateProfileSuccessful, createTweetSuccessful, t]);
@@ -1,18 +1,18 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { Button } from "@material-ui/core";
import React from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { Button } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
buttons: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "flex-end",
alignItems: "justify-content",
marginRight: "15px",
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'flex-end',
alignItems: 'justify-content',
marginRight: '15px',
},
close: {
marginLeft: "8px",
marginLeft: '8px',
},
}));
@@ -27,23 +27,23 @@ export const ControlButtons = ({
const imagePromptVisible = showImagePrompt && !showEmoji;
const primaryButtonText = imagePromptVisible
? t("APPS_TWITTER_SUBMIT_IMAGE")
: t("APPS_TWITTER_TWEET");
? t('APPS_TWITTER_SUBMIT_IMAGE')
: t('APPS_TWITTER_TWEET');
const showCloseButton = showImagePrompt || showEmoji;
return (
<div className={classes.buttons}>
<Button variant="contained" color="primary" onClick={onPrimaryClick}>
<Button variant='contained' color='primary' onClick={onPrimaryClick}>
{primaryButtonText}
</Button>
{showCloseButton && (
<Button
className={classes.close}
variant="contained"
color="secondary"
variant='contained'
color='secondary'
onClick={onCloseClick}
>
{t("APPS_TWITTER_CLOSE_IMAGE")}
{t('APPS_TWITTER_CLOSE_IMAGE')}
</Button>
)}
</div>
@@ -1,20 +1,20 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Button } from "@material-ui/core";
import InsertPhotoIcon from "@material-ui/icons/InsertPhoto";
import EmojiIcon from "@material-ui/icons/SentimentSatisfied";
import { usePhone } from "../../../../os/phone/hooks/usePhone";
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Button } from '@material-ui/core';
import InsertPhotoIcon from '@material-ui/icons/InsertPhoto';
import EmojiIcon from '@material-ui/icons/SentimentSatisfied';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
const useStyles = makeStyles((theme) => ({
buttons: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "flex-start",
paddingLeft: "5px", // re-align left buttons after overriding material-ui spacing
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'flex-start',
paddingLeft: '5px', // re-align left buttons after overriding material-ui spacing
},
button: {
background: "transparent",
minWidth: "45px", // override default material-ui spacing between buttons
background: 'transparent',
minWidth: '45px', // override default material-ui spacing between buttons
},
}));
@@ -29,12 +29,12 @@ export const IconButtons = ({ onImageClick, onEmojiClick }) => {
<div className={classes.buttons}>
{enableImages && (
<Button className={classes.button} onClick={onImageClick}>
<InsertPhotoIcon color="action" />
<InsertPhotoIcon color='action' />
</Button>
)}
{enableEmojis && (
<Button className={classes.button} onClick={onEmojiClick}>
<EmojiIcon color="action" />
<EmojiIcon color='action' />
</Button>
)}
</div>
@@ -1,9 +1,9 @@
import React, { useState } from "react";
import { Button, CircularProgress } from "@material-ui/core";
import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder";
import FavoriteIcon from "@material-ui/icons/Favorite";
import React, { useState } from 'react';
import { Button, CircularProgress } from '@material-ui/core';
import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder';
import FavoriteIcon from '@material-ui/icons/Favorite';
import Nui from "../../../../os/nui-events/utils/Nui";
import Nui from '../../../../os/nui-events/utils/Nui';
const LOADING_TIME = 1250;
@@ -12,7 +12,7 @@ function LikeButton({ tweetId, isLiked }) {
const [loading, setLoading] = useState(false);
const handleClick = () => {
Nui.send("phone:toggleLike", tweetId);
Nui.send('phone:toggleLike', tweetId);
setLoading(true);
window.setTimeout(() => {
setLiked(!liked);
@@ -1,18 +1,18 @@
import React, { useState, useEffect } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Fab } from "@material-ui/core";
import PublishIcon from "@material-ui/icons/Publish";
import React, { useState, useEffect } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Fab } from '@material-ui/core';
import PublishIcon from '@material-ui/icons/Publish';
import { useProfile } from "../../hooks/useProfile";
import { useProfile } from '../../hooks/useProfile';
const useStyles = makeStyles((theme) => ({
root: {
position: "absolute",
bottom: "15px",
right: "15px",
position: 'absolute',
bottom: '15px',
right: '15px',
},
button: {
background: "#00acee",
background: '#00acee',
},
}));
@@ -37,7 +37,7 @@ export function ProfileUpdateButton({ handleClick }) {
<div className={classes.root}>
<Fab
className={classes.button}
color="primary"
color='primary'
onClick={handleClick}
disabled={isLoading}
>
@@ -1,9 +1,9 @@
import React from "react";
import { useSetRecoilState } from "recoil";
import { Button } from "@material-ui/core";
import QuoteIcon from "@material-ui/icons/FormatQuote";
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";
import { twitterState } from '../../hooks/state';
export const QuoteButton = ({ message }) => {
const setModalVisible = useSetRecoilState(twitterState.showCreateTweetModal);
@@ -1,9 +1,9 @@
import React from "react";
import { useSetRecoilState } from "recoil";
import { Button } from "@material-ui/core";
import ReplyIcon from "@material-ui/icons/Reply";
import React from 'react';
import { useSetRecoilState } from 'recoil';
import { Button } from '@material-ui/core';
import ReplyIcon from '@material-ui/icons/Reply';
import { twitterState } from "../../hooks/state";
import { twitterState } from '../../hooks/state';
export const ReplyButton = ({ profile_name }) => {
const setModalVisible = useSetRecoilState(twitterState.showCreateTweetModal);
@@ -1,13 +1,9 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import {
Button,
CircularProgress,
MenuItem
} from "@material-ui/core";
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";
import Nui from '../../../../os/nui-events/utils/Nui';
const LOADING_TIME = 1250;
@@ -16,7 +12,7 @@ function ReportButton({ handleClose, tweetId, isReported }) {
const [loading, setLoading] = useState(false);
const handleClick = () => {
Nui.send("phone:reportTweet", tweetId);
Nui.send('phone:reportTweet', tweetId);
setLoading(true);
window.setTimeout(() => {
setLoading(false);
@@ -26,24 +22,22 @@ function ReportButton({ handleClose, tweetId, isReported }) {
if (isReported) {
return (
<MenuItem onClick={handleClose}>
<DoneIcon />
<span style={{ marginLeft: '5px' }}>{t('APPS_TWITTER_REPORTED')}</span>
</MenuItem >
<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} />
<CircularProgress id='twitter-report-progress' size={22} />
</Button>
);
}
return (
<MenuItem onClick={handleClick}>{t('APPS_TWITTER_REPORT')}</MenuItem >
);
return <MenuItem onClick={handleClick}>{t('APPS_TWITTER_REPORT')}</MenuItem>;
}
export default ReportButton;
@@ -1,16 +1,16 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Fab } from "@material-ui/core";
import SearchIcon from "@material-ui/icons/Search";
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Fab } from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
const useStyles = makeStyles((theme) => ({
root: {
position: "absolute",
bottom: "15px",
right: "15px",
position: 'absolute',
bottom: '15px',
right: '15px',
},
button: {
background: "#00acee",
background: '#00acee',
},
}));
@@ -19,7 +19,7 @@ export function ProfileUpdateButton({ handleClick }) {
return (
<div className={classes.root}>
<Fab className={classes.button} color="primary" onClick={handleClick}>
<Fab className={classes.button} color='primary' onClick={handleClick}>
<SearchIcon />
</Fab>
</div>
@@ -1,16 +1,16 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Fab } from "@material-ui/core";
import CreateIcon from "@material-ui/icons/Create";
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Fab } from '@material-ui/core';
import CreateIcon from '@material-ui/icons/Create';
const useStyles = makeStyles(() => ({
root: {
position: "absolute",
bottom: "75px",
right: "15px",
position: 'absolute',
bottom: '75px',
right: '15px',
},
button: {
background: "#00acee",
background: '#00acee',
},
}));
@@ -19,7 +19,7 @@ export function TweetButton({ openModal }) {
return (
<div className={classes.root}>
<Fab className={classes.button} color="primary" onClick={openModal}>
<Fab className={classes.button} color='primary' onClick={openModal}>
<CreateIcon />
</Fab>
</div>
@@ -1,38 +1,38 @@
import React from "react";
import { IconButton } from "@material-ui/core";
import { makeStyles } from "@material-ui/core/styles";
import CloseIcon from "@material-ui/icons/Close";
import React from 'react';
import { IconButton } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import CloseIcon from '@material-ui/icons/Close';
const useStyles = makeStyles(() => ({
root: {
margin: "2px 15px",
margin: '2px 15px',
},
imageContainer: {
// catch the close button here so it doesn't go all the way up to the modal
position: "relative",
display: "inline-block",
position: 'relative',
display: 'inline-block',
},
imgButton: {
position: "absolute", // show the close button in the top right of the image
top: "2px",
right: "5px",
backgroundColor: "#000",
position: 'absolute', // show the close button in the top right of the image
top: '2px',
right: '5px',
backgroundColor: '#000',
opacity: 0.7,
"&:hover": {
'&:hover': {
// fixes a bug where when the user closes one image material-ui puts
// the hover status on the previous image
backgroundColor: "#000",
backgroundColor: '#000',
},
},
img: {
maxHeight: "125px", // constrain images so we don't overwhelm the UI
maxWidth: "300px",
padding: "0px 3px 3px 0px",
maxHeight: '125px', // constrain images so we don't overwhelm the UI
maxWidth: '300px',
padding: '0px 3px 3px 0px',
},
imgSmall: {
maxHeight: "200px", // constrain images so we don't overwhelm the UI
maxWidth: "100%",
padding: "0px 1px 1px 0px",
maxHeight: '200px', // constrain images so we don't overwhelm the UI
maxWidth: '100%',
padding: '0px 1px 1px 0px',
},
}));
@@ -44,13 +44,13 @@ export const Image = ({ link, handleClick, small }) => {
<IconButton
className={classes.imgButton}
onClick={handleClick}
size="small"
size='small'
>
<CloseIcon />
</IconButton>
)}
<img
alt="small avatar"
alt='small avatar'
className={small ? classes.imgSmall : classes.img}
src={link}
/>
@@ -1,11 +1,11 @@
import React from "react";
import React from 'react';
import Image from "./Image";
import Image from './Image';
export const ImageDisplay = ({ visible, images, removeImage, small }) => {
if (!visible || !images || images.length === 0) return null;
const styles = { margin: small ? "2px 0px" : "2px 15px" };
const styles = { margin: small ? '2px 0px' : '2px 15px' };
return (
<div style={styles}>
@@ -1,16 +1,16 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
import React from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { TextField } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
textField: {
flex: "1 1 100%",
padding: "10px 15px",
marginTop: "15px",
flex: '1 1 100%',
padding: '10px 15px',
marginTop: '15px',
},
textFieldInput: {
fontSize: "22px",
fontSize: '22px',
},
}));
@@ -26,8 +26,8 @@ export const ImagePrompt = ({ visible, value, handleChange }) => {
className={classes.textField}
onChange={handleChange}
multiline
size="small"
placeholder={t("APPS_TWITTER_IMAGE_PLACEHOLDER")}
size='small'
placeholder={t('APPS_TWITTER_IMAGE_PLACEHOLDER')}
inputRef={(input) => input && input.focus()}
/>
);
@@ -1,12 +1,12 @@
import React from "react";
import { shallow } from "enzyme";
import TwitterNotification from "./TwitterNotification";
import React from 'react';
import { shallow } from 'enzyme';
import TwitterNotification from './TwitterNotification';
jest.mock("react-i18next", () => ({
jest.mock('react-i18next', () => ({
useTranslation: () => ({ t: (key) => key }),
}));
jest.mock("../../../../os/phone/hooks/usePhone", () => ({
jest.mock('../../../../os/phone/hooks/usePhone', () => ({
usePhone: jest.fn().mockReturnValue({
config: {
twitter: {
@@ -16,32 +16,32 @@ jest.mock("../../../../os/phone/hooks/usePhone", () => ({
}),
}));
jest.mock("../../hooks/useTwitterNotification", () => ({
jest.mock('../../hooks/useTwitterNotification', () => ({
useTwitterNotification: jest.fn().mockReturnValue({
notification: {
profile_name: "test",
message: "test message",
profile_name: 'test',
message: 'test message',
},
}),
}));
describe("TwitterNotification", () => {
describe('TwitterNotification', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<TwitterNotification />);
});
it("renders", () => {
it('renders', () => {
expect(wrapper).toBeDefined();
});
it("renders profile name", () => {
expect(wrapper.find(".makeStyles-profileName-5").text()).toEqual("@test");
it('renders profile name', () => {
expect(wrapper.find('.makeStyles-profileName-5').text()).toEqual('@test');
});
it("renders message", () => {
expect(wrapper.find(".makeStyles-message-7").text()).toEqual(
"test message"
it('renders message', () => {
expect(wrapper.find('.makeStyles-message-7').text()).toEqual(
'test message'
);
});
});
@@ -1,47 +1,47 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
import TwitterIcon from "@material-ui/icons/Twitter";
import { useTwitterNotification } from "../../hooks/useTwitterNotification";
import Notification from "../../../../ui/components/Notification";
import { usePhone } from "../../../../os/phone/hooks/usePhone";
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import TwitterIcon from '@material-ui/icons/Twitter';
import { useTwitterNotification } from '../../hooks/useTwitterNotification';
import Notification from '../../../../ui/components/Notification';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
content: {
padding: theme.spacing(2),
overflowY: "hidden",
overflowY: 'hidden',
},
title: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "space-between",
alignItems: "center",
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'space-between',
alignItems: 'center',
},
titleLeft: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "flex-start",
alignItems: "center",
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'flex-start',
alignItems: 'center',
},
icon: {
marginTop: "3px",
marginRight: "5px",
marginTop: '3px',
marginRight: '5px',
},
profileName: {
marginBottom: "3px",
marginBottom: '3px',
},
justNow: {
fontSize: "18px",
fontStyle: "italic",
paddingRight: "3px",
fontSize: '18px',
fontStyle: 'italic',
paddingRight: '3px',
},
message: {
fontSize: "16px",
overflow: "hidden",
display: "-webkit-box",
fontSize: '16px',
overflow: 'hidden',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: "vertical",
WebkitBoxOrient: 'vertical',
},
})
);
@@ -77,7 +77,7 @@ function TwitterNotification() {
</div>
<div className={classes.profileName}>{profileName}</div>
</div>
<div className={classes.justNow}>{t("APPS_TWITTER_JUST_NOW")}</div>
<div className={classes.justNow}>{t('APPS_TWITTER_JUST_NOW')}</div>
</div>
<div className={classes.message}>{notification.message}</div>
</div>
@@ -1,23 +1,23 @@
import React, { useState } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next";
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
import Nui from "../../../../os/nui-events/utils/Nui";
import { useProfile } from "../../hooks/useProfile";
import Avatar from "../Avatar";
import ProfileField from "./ProfileField";
import ProfileUpdateButton from "../buttons/ProfileUpdateButton";
import { usePhone } from "../../../../os/phone/hooks/usePhone";
import Nui from '../../../../os/nui-events/utils/Nui';
import { useProfile } from '../../hooks/useProfile';
import Avatar from '../Avatar';
import ProfileField from './ProfileField';
import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
const useStyles = makeStyles((theme) => ({
root: {
position: "relative",
width: "100%",
height: "100%",
padding: "15px",
position: 'relative',
width: '100%',
height: '100%',
padding: '15px',
},
spacer: {
height: "8px",
height: '8px',
},
}));
@@ -32,11 +32,11 @@ export function Profile() {
// Annoyingling adding conditionals above this line to not render
// when profile === null results in a react error that different
// amounts of hooks are rendering
const [avatarUrl, handleAvatarChange] = useState(profile.avatar_url || "");
const [name, handleNameChange] = useState(profile.profile_name || "");
const [bio, handleBioChange] = useState(profile.bio || "");
const [location, handleLocationChange] = useState(profile.location || "");
const [job, handleJobChange] = useState(profile.job || "");
const [avatarUrl, handleAvatarChange] = useState(profile.avatar_url || '');
const [name, handleNameChange] = useState(profile.profile_name || '');
const [bio, handleBioChange] = useState(profile.bio || '');
const [location, handleLocationChange] = useState(profile.location || '');
const [job, handleJobChange] = useState(profile.job || '');
const handleUpdate = () => {
const data = {
@@ -46,7 +46,7 @@ export function Profile() {
location,
job,
};
Nui.send("phone:updateTwitterProfile", data);
Nui.send('phone:updateTwitterProfile', data);
};
// fetching the config is an asynchronous call so defend against it
@@ -59,30 +59,30 @@ export function Profile() {
{enableAvatars && <Avatar avatarUrl={avatarUrl} showInvalidImage />}
<div className={classes.spacer} />
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_AVATAR")}
label={t('APPS_TWITTER_EDIT_PROFILE_AVATAR')}
value={avatarUrl}
handleChange={handleAvatarChange}
allowChange={enableAvatars}
/>
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_NAME")}
label={t('APPS_TWITTER_EDIT_PROFILE_NAME')}
value={name}
handleChange={handleNameChange}
allowChange={allowEdtiableProfileName}
/>
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_BIO")}
label={t('APPS_TWITTER_EDIT_PROFILE_BIO')}
value={bio}
handleChange={handleBioChange}
multiline
/>
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_LOCATION")}
label={t('APPS_TWITTER_EDIT_PROFILE_LOCATION')}
value={location}
handleChange={handleLocationChange}
/>
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_JOB")}
label={t('APPS_TWITTER_EDIT_PROFILE_JOB')}
value={job}
handleChange={handleJobChange}
/>
@@ -1,14 +1,14 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { TextField } from '@material-ui/core';
const useStyles = makeStyles({
formContainer: {
width: "100%",
marginTop: "8px",
width: '100%',
marginTop: '8px',
},
textField: {
width: "100%",
width: '100%',
},
});
@@ -1,21 +1,21 @@
import React, { useState } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { useTranslation } from "react-i18next";
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
import Nui from "../../../../os/nui-events/utils/Nui";
import { useProfile } from "../../hooks/useProfile";
import ProfileField from "./ProfileField";
import ProfileUpdateButton from "../buttons/ProfileUpdateButton";
import Nui from '../../../../os/nui-events/utils/Nui';
import { useProfile } from '../../hooks/useProfile';
import ProfileField from './ProfileField';
import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
const useStyles = makeStyles((theme) => ({
root: {
position: "relative",
width: "100%",
height: "100%",
padding: "15px",
position: 'relative',
width: '100%',
height: '100%',
padding: '15px',
},
spacer: {
height: "8px",
height: '8px',
},
}));
@@ -24,20 +24,20 @@ export function ProfilePrompt() {
const { t } = useTranslation();
const { profile } = useProfile();
const [name, handleNameChange] = useState(profile.profile_name || "");
const [name, handleNameChange] = useState(profile.profile_name || '');
const handleUpdate = () => {
const data = {
...profile,
profile_name: name,
};
Nui.send("phone:updateTwitterProfile", data);
Nui.send('phone:updateTwitterProfile', data);
};
return (
<div className={classes.root}>
<ProfileField
label={t("APPS_TWITTER_EDIT_PROFILE_NAME")}
label={t('APPS_TWITTER_EDIT_PROFILE_NAME')}
value={name}
handleChange={handleNameChange}
allowChange
@@ -1,16 +1,11 @@
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 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';
/**
* Ok this is some bullshit. Due to either scaling issues or the NUI
* overlay being different than the display resolution just letting
@@ -29,7 +24,7 @@ import ReportButton from '../buttons/ReportButton';
* of the anchor element
*/
function calculateVerticalOffset(top: number): number {
return top * 0.20 - 38;
return top * 0.2 - 38;
}
export const ShowMore = ({ id, isReported, isMine }) => {
@@ -41,11 +36,11 @@ export const ShowMore = ({ id, isReported, isMine }) => {
if (!config) return null;
const handleClick = (event: React.MouseEvent) => {
const element = event.currentTarget
const element = event.currentTarget;
setAnchorEl(element);
const top = window.pageYOffset + element.getBoundingClientRect().top
setVerticalOffset(calculateVerticalOffset(top));
const top = window.pageYOffset + element.getBoundingClientRect().top;
setVerticalOffset(calculateVerticalOffset(top));
};
const handleClose = () => {
@@ -54,36 +49,51 @@ export const ShowMore = ({ id, isReported, isMine }) => {
};
const handleDeleteTweet = () => {
Nui.send("phone:deleteTweet", id);
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;
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>
<>
<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>
</>
);
};
@@ -1,63 +1,63 @@
import React, { memo } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
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";
} from '@material-ui/core';
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 { 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 { QuoteButton } from '../buttons/QuoteButton';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
const useStyles = makeStyles(() => ({
root: {
overflowX: "hidden",
display: "flex",
flexFlow: "row nowrap",
alignItems: "flex-start",
width: "100%",
marginTop: "3px",
overflowX: 'hidden',
display: 'flex',
flexFlow: 'row nowrap',
alignItems: 'flex-start',
width: '100%',
marginTop: '3px',
},
content: {
display: "flex",
marginTop: "-10px", // easier to do this here than override the MUI styles
flexFlow: "column nowrap",
width: "100%",
display: 'flex',
marginTop: '-10px', // easier to do this here than override the MUI styles
flexFlow: 'column nowrap',
width: '100%',
},
primary: {
display: "flex",
flexFlow: "row nowrap",
width: "100%",
alignItems: "flex-end",
display: 'flex',
flexFlow: 'row nowrap',
width: '100%',
alignItems: 'flex-end',
},
profile: {
fontSize: "18px",
fontWeight: "bold",
fontSize: '18px',
fontWeight: 'bold',
},
date: {
marginLeft: "10px",
fontSize: "14px",
marginLeft: '10px',
fontSize: '14px',
},
message: {
fontSize: "18px",
color: "rgba(255, 255, 255, 0.7)",
fontSize: '18px',
color: 'rgba(255, 255, 255, 0.7)',
},
buttonContainer: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "space-between",
width: "100%",
marginLeft: "-20px", // easier to do this here than override the MUI styles
marginTop: "3px",
}
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'space-between',
width: '100%',
marginLeft: '-20px', // easier to do this here than override the MUI styles
marginTop: '3px',
},
}));
export const Tweet = (tweet) => {
@@ -81,15 +81,15 @@ 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}` : "";
const formattedMessage = message.replace(/\n\r?/g, '<br />');
const profileName = profile_name ? `@${profile_name}` : '';
return (
<ListItem className={classes.root} divider>
{enableAvatars && (
<ListItemAvatar>
<MuiAvatar>
<Avatar avatarUrl={avatar_url} height="40px" width="40px" />
<Avatar avatarUrl={avatar_url} height='40px' width='40px' />
</MuiAvatar>
</ListItemAvatar>
)}
@@ -98,9 +98,9 @@ export const Tweet = (tweet) => {
<div className={classes.profile}>{profileName}</div>
<Typography
className={classes.date}
component="div"
variant="body2"
color="textSecondary"
component='div'
variant='body2'
color='textSecondary'
>
{secondsToHumanReadable(t, seconds_since_tweet)}
</Typography>
@@ -1,8 +1,8 @@
import React, { useEffect, useState, memo } from "react";
import React, { useEffect, useState, memo } from 'react';
import { List } from "../../../../ui/components/List";
import Tweet from "./Tweet";
import TweetSkeletonList from "./TweetSkeletonList";
import { List } from '../../../../ui/components/List';
import Tweet from './Tweet';
import TweetSkeletonList from './TweetSkeletonList';
const MINIMUM_LOAD_TIME = 700;
@@ -21,7 +21,6 @@ export function TweetList({ tweets }) {
// another flash to the tweets screen.
const hasLoaded = tweets && minimumLoadPassed;
if (!hasLoaded) return <TweetSkeletonList />;
return (
<List>
@@ -1,14 +1,14 @@
import React, { useEffect } from "react";
import React, { useEffect } from 'react';
import Nui from "../../../../os/nui-events/utils/Nui";
import { useTweets } from "../../hooks/useTweets";
import TweetList from "./TweetList";
import Nui from '../../../../os/nui-events/utils/Nui';
import { useTweets } from '../../hooks/useTweets';
import TweetList from './TweetList';
export function TweetListContainer() {
const { tweets } = useTweets();
useEffect(() => {
Nui.send("phone:fetchTweets", {});
Nui.send('phone:fetchTweets', {});
}, []);
return <TweetList tweets={tweets} />;
@@ -1,20 +1,20 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
import { usePhone } from "../../../../os/phone/hooks/usePhone";
import React from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { TextField } from '@material-ui/core';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
const useStyles = makeStyles((theme) => ({
textField: {
flex: "1 1 100%",
padding: "10px 15px",
marginTop: "15px",
flex: '1 1 100%',
padding: '10px 15px',
marginTop: '15px',
},
textFieldInput: {
fontSize: "22px",
fontSize: '22px',
},
display: {
height: "200px",
height: '200px',
},
}));
@@ -28,7 +28,7 @@ export const TweetMessage = ({ message, handleChange }) => {
const overCharacterLimit =
message.trim().length > config.twitter.characterLimit;
const characterWarningPrompt = `${t(
"APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT"
'APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT'
)} (${config.twitter.characterLimit})`;
return (
@@ -38,7 +38,7 @@ export const TweetMessage = ({ message, handleChange }) => {
className={classes.textField}
onChange={handleChange}
multiline
placeholder={t("APPS_TWITTER_TWEET_MESSAGE_PLACEHOLDER")}
placeholder={t('APPS_TWITTER_TWEET_MESSAGE_PLACEHOLDER')}
inputRef={(input) => input && input.focus()}
error={overCharacterLimit}
helperText={overCharacterLimit ? characterWarningPrompt : null}
@@ -1,21 +1,21 @@
import React from "react";
import Divider from "@material-ui/core/Divider";
import { makeStyles } from "@material-ui/core/styles";
import Skeleton from "@material-ui/lab/Skeleton";
import React from 'react';
import Divider from '@material-ui/core/Divider';
import { makeStyles } from '@material-ui/core/styles';
import Skeleton from '@material-ui/lab/Skeleton';
const useStyles = makeStyles({
root: {
width: "100%",
padding: "15px",
display: "flex",
flexFlow: "row nowrap",
marginTop: "3px",
marginBottom: "3px",
width: '100%',
padding: '15px',
display: 'flex',
flexFlow: 'row nowrap',
marginTop: '3px',
marginBottom: '3px',
},
left: {},
right: {
marginLeft: "15px",
marginTop: "-5px",
marginLeft: '15px',
marginTop: '-5px',
},
});
@@ -25,11 +25,11 @@ export default function TweetSkeleton() {
<>
<div className={classes.root}>
<div className={classes.left}>
<Skeleton variant="circle" width={60} height={60} />
<Skeleton variant='circle' width={60} height={60} />
</div>
<div className={classes.right}>
<Skeleton variant="text" />
<Skeleton variant="rect" width={250} height={118} />
<Skeleton variant='text' />
<Skeleton variant='rect' width={250} height={118} />
</div>
</div>
@@ -1,7 +1,7 @@
import React from "react";
import React from 'react';
import { List } from "../../../../ui/components/List";
import TweetSkeleton from "./TweetSkeleton";
import { List } from '../../../../ui/components/List';
import TweetSkeleton from './TweetSkeleton';
export function TweetSkeletonList() {
return (
+13 -13
View File
@@ -1,44 +1,44 @@
import { atom } from "recoil";
import { atom } from 'recoil';
export const twitterState = {
profile: atom({
key: "profile",
key: 'profile',
default: {},
}),
tweets: atom({
key: "tweets",
key: 'tweets',
default: null,
}),
filteredTweets: atom({
key: "filteredTweets",
key: 'filteredTweets',
default: null,
}),
showCreateTweetModal: atom({
key: "showCreateTweetModal",
key: 'showCreateTweetModal',
default: false,
}),
modalMessage: atom({
key: "modalMessage",
default: "",
key: 'modalMessage',
default: '',
}),
createTweetLoading: atom({
key: "createTweetLoading",
key: 'createTweetLoading',
default: false,
}),
createTweetSuccessful: atom({
key: "createTweetSuccessful",
key: 'createTweetSuccessful',
default: null,
}),
updateProfileLoading: atom({
key: "updateProfileLoading",
key: 'updateProfileLoading',
default: false,
}),
updateProfileSuccess: atom({
key: "updateProfileSuccess",
key: 'updateProfileSuccess',
default: null,
}),
notification: atom({
key: "notification",
key: 'notification',
default: null,
})
}),
};
@@ -1,5 +1,5 @@
import { useRecoilState } from "recoil";
import { twitterState } from "./state";
import { useRecoilState } from 'recoil';
import { twitterState } from './state';
export const useFilteredTweets = () => {
const [tweets, setTweets] = useRecoilState(twitterState.filteredTweets);
+2 -2
View File
@@ -1,5 +1,5 @@
import { useRecoilState } from "recoil";
import { twitterState } from "./state";
import { useRecoilState } from 'recoil';
import { twitterState } from './state';
export const useModal = () => {
const [modalVisible, setModalVisible] = useRecoilState(
+2 -2
View File
@@ -1,5 +1,5 @@
import { useRecoilValue, useRecoilState } from "recoil";
import { twitterState } from "./state";
import { useRecoilValue, useRecoilState } from 'recoil';
import { twitterState } from './state';
interface IProfile {
profile_name?: string;
@@ -1,6 +1,6 @@
import { useRecoilValue, useRecoilState } from "recoil";
import { useRecoilValue, useRecoilState } from 'recoil';
import { twitterState } from "./state";
import { twitterState } from './state';
export const useTweetStatus = () => {
const createTweetLoading = useRecoilValue(twitterState.createTweetLoading);
+2 -2
View File
@@ -1,5 +1,5 @@
import { useRecoilValue } from "recoil";
import { twitterState } from "./state";
import { useRecoilValue } from 'recoil';
import { twitterState } from './state';
export const useTweets = () => {
const tweets = useRecoilValue(twitterState.tweets);
@@ -1,10 +1,10 @@
import { useSetRecoilState } from "recoil";
import { v4 as uuidv4 } from "uuid";
import { useSetRecoilState } from 'recoil';
import { v4 as uuidv4 } from 'uuid';
import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent";
import { IMAGE_DELIMITER } from "../utils/images";
import { APP_TWITTER } from "../utils/constants";
import { twitterState } from "./state";
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { IMAGE_DELIMITER } from '../utils/images';
import { APP_TWITTER } from '../utils/constants';
import { twitterState } from './state';
/**
* Perform all necessary processing/transforms from the raw database
@@ -67,12 +67,12 @@ export const useTwitterService = () => {
setFilteredTweets(tweets.map(processTweet));
};
useNuiEvent(APP_TWITTER, "getOrCreateTwitterProfile", _setProfile);
useNuiEvent(APP_TWITTER, "updateProfileLoading", setUpdateProfileLoading);
useNuiEvent(APP_TWITTER, "updateProfileResult", _setUpdateProfileSuccess);
useNuiEvent(APP_TWITTER, "fetchTweets", _setTweets);
useNuiEvent(APP_TWITTER, "fetchTweetsFiltered", _setFilteredTweets);
useNuiEvent(APP_TWITTER, "createTweetLoading", setCreateLoading);
useNuiEvent(APP_TWITTER, "createTweetResult", _setCreateSuccess);
useNuiEvent(APP_TWITTER, "createTweetBroadcast", _setNotification);
useNuiEvent(APP_TWITTER, 'getOrCreateTwitterProfile', _setProfile);
useNuiEvent(APP_TWITTER, 'updateProfileLoading', setUpdateProfileLoading);
useNuiEvent(APP_TWITTER, 'updateProfileResult', _setUpdateProfileSuccess);
useNuiEvent(APP_TWITTER, 'fetchTweets', _setTweets);
useNuiEvent(APP_TWITTER, 'fetchTweetsFiltered', _setFilteredTweets);
useNuiEvent(APP_TWITTER, 'createTweetLoading', setCreateLoading);
useNuiEvent(APP_TWITTER, 'createTweetResult', _setCreateSuccess);
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', _setNotification);
};
+3 -3
View File
@@ -1,3 +1,3 @@
export const IMG_DEFAULT_AVATAR = "./media/twitter/egg.png";
export const IMG_INVALID_AVATAR = "./media/twitter/invalid.png";
export const APP_TWITTER = "TWITTER";
export const IMG_DEFAULT_AVATAR = './media/twitter/egg.png';
export const IMG_INVALID_AVATAR = './media/twitter/invalid.png';
export const APP_TWITTER = 'TWITTER';
+1 -1
View File
@@ -3,7 +3,7 @@
// hash, etc.) are often found in URLS (even though it's not technically
// within specification). To get around this we have our own delimiter
// here we'll use to join and split these strings
export const IMAGE_DELIMITER = "||!||";
export const IMAGE_DELIMITER = '||!||';
/**
* Validate that the URL successfully loads in the browser
+4 -4
View File
@@ -2,10 +2,10 @@ const ONE_MINUTE = 60;
const ONE_HOUR = 60 * ONE_MINUTE;
const ONE_DAY = 24 * ONE_HOUR;
const JUST_NOW = "APPS_TWITTER_TIME_JUST_NOW";
const MINUTES = "APPS_TWITTER_TIME_MINUTES";
const HOURS = "APPS_TWITTER_TIME_HOURS";
const DAYS = "APPS_TWITTER_TIME_DAYS";
const JUST_NOW = 'APPS_TWITTER_TIME_JUST_NOW';
const MINUTES = 'APPS_TWITTER_TIME_MINUTES';
const HOURS = 'APPS_TWITTER_TIME_HOURS';
const DAYS = 'APPS_TWITTER_TIME_DAYS';
/**
* Convert seconds to a human readable format i.e. "Just Now", "2m", "3d"