diff --git a/phone/src/apps/twitter/components/AddTweetModal.js b/phone/src/apps/twitter/components/AddTweetModal.js
index 373050c..cd1623c 100644
--- a/phone/src/apps/twitter/components/AddTweetModal.js
+++ b/phone/src/apps/twitter/components/AddTweetModal.js
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react";
+import { useRecoilState } from "recoil";
import { makeStyles } from "@material-ui/core/styles";
import { Button, Paper } from "@material-ui/core";
import CloseIcon from "@material-ui/icons/Close";
@@ -7,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";
import Nui from "../../../os/nui-events/utils/Nui";
import { IMAGE_DELIMITER } from "../utils/images";
import { withValidImage } from "../utils/images";
+import { useModal } from "../hooks/useModal";
import EmojiSelect from "./EmojiSelect";
import ImageDisplay from "./ImageDisplay";
import ImagePrompt from "./ImagePrompt";
@@ -16,17 +18,19 @@ import IconButtons from "./IconButtons";
import AddTweetStatus from "./AddTweetStatus";
const useStyles = makeStyles((theme) => ({
- button: {
- margin: 5,
- marginTop: 20,
- },
root: {
- zIndex: 2,
- background: "#232323",
+ zIndex: 10,
+ background: "#424242",
marginTop: "15px",
width: "90%",
display: "flex",
flexFlow: "column nowrap",
+ position: "absolute",
+ top: "35px",
+ },
+ button: {
+ margin: 5,
+ marginTop: 20,
},
close: {
position: "absolute",
@@ -59,13 +63,14 @@ const useStyles = makeStyles((theme) => ({
},
}));
-export const AddTweetModal = ({ visible, handleClose }) => {
+export const AddTweetModal = () => {
const classes = useStyles();
+ const { message, setMessage, modalVisible, setModalVisible } = useModal();
+
const [showEmoji, setShowEmoji] = useState(false);
const [showImagePrompt, setShowImagePrompt] = useState(false);
const [link, setLink] = useState("");
- const [message, setMessage] = useState("");
const [images, setImages] = useState([]);
const reset = () => {
@@ -79,7 +84,7 @@ export const AddTweetModal = ({ visible, handleClose }) => {
const _handleClose = () => {
reset();
- handleClose();
+ setModalVisible(false);
};
// when the user presses escape we should close the modal
@@ -95,11 +100,13 @@ export const AddTweetModal = ({ visible, handleClose }) => {
return () => window.removeEventListener("keydown", listener);
}, []);
- const showHideClassName = visible
+ const showHideClassName = modalVisible
? classes.displayBlock
: classes.displayNone;
const submitTweet = () => {
+ if (message.trim().length === 0) return;
+
const data = {
message,
images:
diff --git a/phone/src/apps/twitter/components/EmojiSelect.js b/phone/src/apps/twitter/components/EmojiSelect.js
index 97bec24..9bdd44c 100644
--- a/phone/src/apps/twitter/components/EmojiSelect.js
+++ b/phone/src/apps/twitter/components/EmojiSelect.js
@@ -1,29 +1,16 @@
import React, { memo } from "react";
-import { makeStyles } from "@material-ui/core/styles";
import { Picker } from "emoji-mart";
import "./emoji.css";
import "emoji-mart/css/emoji-mart.css";
-const useStyles = makeStyles((theme) => ({
- emojiPicker: {
- background: "none",
- border: "none",
- boxShadow: "none",
- },
-}));
-
export const EmojiSelect = ({ visible, onEmojiClick }) => {
- const classes = useStyles();
-
if (!visible) return null;
return (
diff --git a/phone/src/apps/twitter/components/QuoteButton.js b/phone/src/apps/twitter/components/QuoteButton.js
new file mode 100644
index 0000000..e05020f
--- /dev/null
+++ b/phone/src/apps/twitter/components/QuoteButton.js
@@ -0,0 +1,24 @@
+import React from "react";
+import Button from "@material-ui/core/Button";
+import QuoteIcon from "@material-ui/icons/FormatQuote";
+
+import { useModal } from "../hooks/useModal";
+
+export const QuoteButton = ({ message }) => {
+ const { setMessage, setModalVisible } = useModal();
+
+ const handleClick = () => {
+ setMessage(`> ${message}
+
+`);
+ setModalVisible(true);
+ };
+
+ return (
+
+ );
+};
+
+export default QuoteButton;
diff --git a/phone/src/apps/twitter/components/ReplyButton.js b/phone/src/apps/twitter/components/ReplyButton.js
new file mode 100644
index 0000000..1de8754
--- /dev/null
+++ b/phone/src/apps/twitter/components/ReplyButton.js
@@ -0,0 +1,21 @@
+import React from "react";
+import Button from "@material-ui/core/Button";
+import ReplyIcon from "@material-ui/icons/Reply";
+import { useModal } from "../hooks/useModal";
+
+export const ReplyButton = ({ profile_name }) => {
+ const { setMessage, setModalVisible } = useModal();
+
+ const handleClick = () => {
+ setMessage(`@${profile_name} `);
+ setModalVisible(true);
+ };
+
+ return (
+
+ );
+};
+
+export default ReplyButton;
diff --git a/phone/src/apps/twitter/components/Tweet.js b/phone/src/apps/twitter/components/Tweet.js
index 739351e..b6f68d5 100644
--- a/phone/src/apps/twitter/components/Tweet.js
+++ b/phone/src/apps/twitter/components/Tweet.js
@@ -7,13 +7,13 @@ import MuiAvatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";
import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder";
-import ReplyIcon from "@material-ui/icons/Reply";
-import QuoteIcon from "@material-ui/icons/FormatQuote";
import { ListItem } from "../../../ui/components/ListItem";
import { secondsToHumanReadable } from "../utils/time";
+import ReplyButton from "./ReplyButton";
import ImageDisplay from "./ImageDisplay";
import Avatar from "./Avatar";
+import { QuoteButton } from "./QuoteButton";
const useStyles = makeStyles(() => ({
root: {
@@ -22,6 +22,7 @@ const useStyles = makeStyles(() => ({
flexFlow: "row nowrap",
alignItems: "flex-start",
width: "100%",
+ marginTop: "3px",
},
content: {
display: "flex",
@@ -52,9 +53,12 @@ export const Tweet = (tweet) => {
const classes = useStyles();
const { t } = useTranslation();
+ // 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, "
");
const Message = () => (
<>
-
{message}
+
>
);
@@ -83,15 +87,11 @@ export const Tweet = (tweet) => {
} secondary={
} />
-
+
-
+
diff --git a/phone/src/apps/twitter/components/TweetList.js b/phone/src/apps/twitter/components/TweetList.js
index a8e21f7..85df6b5 100644
--- a/phone/src/apps/twitter/components/TweetList.js
+++ b/phone/src/apps/twitter/components/TweetList.js
@@ -1,31 +1,9 @@
-import React, { useEffect } from "react";
+import React from "react";
-import Nui from "../../../os/nui-events/utils/Nui";
import { List } from "../../../ui/components/List";
-import { useTweets } from "../hooks/useTweets";
import Tweet from "./Tweet";
-const TWEETS_REFRESH_RATE = 50000000; // TODO move this to twitter config
-
-export function TweetList() {
- const { tweets } = useTweets();
-
- useEffect(() => {
- Nui.send("phone:fetchTweets", {});
-
- // this is a polling implementation. It is possible that
- // there is some interaction where, on a new tweet, all
- // clients are sent the updated query data. Until that can
- // be accomplished this is naive but robust.
- //
- // 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", {});
- }, TWEETS_REFRESH_RATE);
- return () => window.clearTimeout(timeout);
- }, []);
-
+export function TweetList({ tweets }) {
return (
{tweets.map((tweet) => (
diff --git a/phone/src/apps/twitter/components/TweetListContainer.js b/phone/src/apps/twitter/components/TweetListContainer.js
new file mode 100644
index 0000000..55b6288
--- /dev/null
+++ b/phone/src/apps/twitter/components/TweetListContainer.js
@@ -0,0 +1,32 @@
+import React, { useEffect } from "react";
+
+import Nui from "../../../os/nui-events/utils/Nui";
+import { List } from "../../../ui/components/List";
+import { useTweets } from "../hooks/useTweets";
+import TweetList from "./TweetList";
+
+const TWEETS_REFRESH_RATE = 50000000; // TODO move this to twitter config
+
+export function TweetListContainer() {
+ const { tweets } = useTweets();
+
+ useEffect(() => {
+ Nui.send("phone:fetchTweets", {});
+
+ // this is a polling implementation. It is possible that
+ // there is some interaction where, on a new tweet, all
+ // clients are sent the updated query data. Until that can
+ // be accomplished this is naive but robust.
+ //
+ // 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", {});
+ }, TWEETS_REFRESH_RATE);
+ return () => window.clearTimeout(timeout);
+ }, []);
+
+ return ;
+}
+
+export default TweetListContainer;
diff --git a/phone/src/apps/twitter/components/TweetMessage.js b/phone/src/apps/twitter/components/TweetMessage.js
index 888f1a8..4d086e9 100644
--- a/phone/src/apps/twitter/components/TweetMessage.js
+++ b/phone/src/apps/twitter/components/TweetMessage.js
@@ -1,4 +1,4 @@
-import React from "react";
+import React, { useEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
@@ -20,6 +20,7 @@ const useStyles = makeStyles((theme) => ({
export const TweetMessage = ({ message, handleChange }) => {
const classes = useStyles();
const { t } = useTranslation();
+
return (
{
onChange={handleChange}
multiline
placeholder={t("APPS_TWITTER_PLACEHOLDER")}
+ inputRef={(input) => input && input.focus()}
/>
);
};
diff --git a/phone/src/apps/twitter/components/TwitterApp.js b/phone/src/apps/twitter/components/TwitterApp.js
index e81295a..24bb597 100644
--- a/phone/src/apps/twitter/components/TwitterApp.js
+++ b/phone/src/apps/twitter/components/TwitterApp.js
@@ -1,10 +1,10 @@
import React, { useState, useEffect } from "react";
-import { makeStyles } from "@material-ui/core";
+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 TweetList from "./TweetList";
+import TweetListContainer from "./TweetListContainer";
import AddTweetModal from "./AddTweetModal";
import { AppLoader } from "../../../ui/components/AppLoader";
import TweetButton from "./TweetButton";
@@ -14,18 +14,33 @@ import TwitterProfile from "./profile/TwitterProfile";
import { useProfile } from "../hooks/useProfile";
import "./twitter.css";
+import { useModal } from "../hooks/useModal";
+
+const useStyles = makeStyles((theme) => ({
+ backgroundModal: {
+ background: "black",
+ opacity: "0.6",
+ position: "absolute",
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ zIndex: 5,
+ },
+}));
// TODO move this to the router so the application back button works
const PAGE_COMPONENT_MAPPING = {
- 0: ,
- 1: ,
+ 0: ,
+ 1: ,
2: ,
};
const MINIMUM_LOAD_TIME = 750;
export const TwitterApp = () => {
+ const classes = useStyles();
+ const { modalVisible, setModalVisible } = useModal();
const [minimumLoadPassed, setMimimumLoadPassed] = useState(false);
- const [modalVisible, setModalVisible] = useState(false);
const [activePage, setActivePage] = useState(0);
const { profile } = useProfile();
@@ -57,11 +72,10 @@ export const TwitterApp = () => {
return (