diff --git a/phone/src/apps/twitter/components/TwitterApp.js b/phone/src/apps/twitter/components/TwitterApp.js index 7e96138..46d1465 100644 --- a/phone/src/apps/twitter/components/TwitterApp.js +++ b/phone/src/apps/twitter/components/TwitterApp.js @@ -18,6 +18,7 @@ import TwitterSearch from "./TwitterSearch"; import "./twitter.css"; import "emoji-mart/css/emoji-mart.css"; import { useProfile } from "../hooks/useProfile"; +import ProfilePrompt from "./profile/ProfilePrompt"; const useStyles = makeStyles(() => ({ backgroundModal: { @@ -59,9 +60,14 @@ export const TwitterApp = () => { return () => window.clearTimeout(timeout); }, []); + // before any other action can be taken by the user we force + // them have a profile name + const promptProfileName = + profile && (!profile.profile_name || !profile.profile_name.trim()); + const openModal = () => setModalVisible(true); const handlePageChange = (e, page) => setActivePage(page); - const showTweetButton = activePage === 0; + const showTweetButton = !promptProfileName && activePage === 0; return ( @@ -69,18 +75,24 @@ export const TwitterApp = () => {
- - - - - + {promptProfileName ? ( + + ) : ( + + + + + + )} {showTweetButton && } - + {!promptProfileName && ( + + )} ); }; diff --git a/phone/src/apps/twitter/components/profile/ProfilePrompt.js b/phone/src/apps/twitter/components/profile/ProfilePrompt.js new file mode 100644 index 0000000..307aecb --- /dev/null +++ b/phone/src/apps/twitter/components/profile/ProfilePrompt.js @@ -0,0 +1,49 @@ +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"; + +const useStyles = makeStyles((theme) => ({ + root: { + position: "relative", + width: "100%", + height: "100%", + padding: "15px", + }, + spacer: { + height: "8px", + }, +})); + +export function ProfilePrompt() { + const classes = useStyles(); + const { t } = useTranslation(); + const { profile } = useProfile(); + const [name, handleNameChange] = useState(profile.profile_name || ""); + + const handleUpdate = () => { + const data = { + ...profile, + profile_name: name, + }; + Nui.send("phone:updateTwitterProfile", data); + }; + + return ( +
+ + +
+ ); +} + +export default ProfilePrompt; diff --git a/phone/src/apps/twitter/components/tweet/Tweet.js b/phone/src/apps/twitter/components/tweet/Tweet.js index 7d4b12f..5f87c9b 100644 --- a/phone/src/apps/twitter/components/tweet/Tweet.js +++ b/phone/src/apps/twitter/components/tweet/Tweet.js @@ -80,6 +80,8 @@ export const Tweet = (tweet) => { // are stored into the database into html for the UI to render const formattedMessage = message.replace(/\n\r?/g, "
"); + const profileName = profile_name ? `@${profile_name}` : ""; + return ( {enableAvatars && ( @@ -91,7 +93,7 @@ export const Tweet = (tweet) => { )}
-
{`@${profile_name}`}
+
{profileName}