From 86e79354d7a969c8bca4a07418b151a916e88ab3 Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Mon, 31 Oct 2022 12:14:22 -0400 Subject: [PATCH] Add new Welcome experience --- .../chats/components/chat-page/chat-page.tsx | 58 ++++++++------- .../chat-page/components/chat-page-main.tsx | 10 +-- .../chat-page/components/welcome.tsx | 71 +++++++++++++------ 3 files changed, 85 insertions(+), 54 deletions(-) diff --git a/app/soapbox/features/chats/components/chat-page/chat-page.tsx b/app/soapbox/features/chats/components/chat-page/chat-page.tsx index f26bb2e5af..728f4bfc24 100644 --- a/app/soapbox/features/chats/components/chat-page/chat-page.tsx +++ b/app/soapbox/features/chats/components/chat-page/chat-page.tsx @@ -4,6 +4,7 @@ import { Route, Switch } from 'react-router-dom'; import { Stack } from 'soapbox/components/ui'; import { useChatContext } from 'soapbox/contexts/chat-context'; +import { useOwnAccount } from 'soapbox/hooks'; import { useChat } from 'soapbox/queries/chats'; import ChatPageMain from './components/chat-page-main'; @@ -16,6 +17,9 @@ interface IChatPage { } const ChatPage: React.FC = ({ chatId }) => { + const account = useOwnAccount(); + const isOnboarded = account?.chats_onboarded; + const { chat, setChat } = useChatContext(); const { chat: chatQueryResult } = useChat(chatId); @@ -62,32 +66,36 @@ const ChatPage: React.FC = ({ chatId }) => { style={{ height }} className='h-screen bg-white dark:bg-primary-900 text-gray-900 dark:text-gray-100 shadow-lg dark:shadow-none overflow-hidden sm:rounded-t-xl' > -
- - - + {isOnboarded ? ( +
+ + + - - - - - - - - - - - - - -
+ + + + + + + + + + + + + +
+ ) : ( + + )} ); }; diff --git a/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx b/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx index 2c7647663b..7ecaf9b4a2 100644 --- a/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx +++ b/app/soapbox/features/chats/components/chat-page/components/chat-page-main.tsx @@ -7,14 +7,13 @@ import List, { ListItem } from 'soapbox/components/list'; import { Avatar, HStack, Icon, IconButton, Menu, MenuButton, MenuItem, MenuList, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification_badge'; import { useChatContext } from 'soapbox/contexts/chat-context'; -import { useAppDispatch, useAppSelector, useOwnAccount } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { MessageExpirationValues, useChatActions } from 'soapbox/queries/chats'; import { secondsToDays } from 'soapbox/utils/numbers'; import Chat from '../../chat'; import Blankslate from './blankslate'; -import Welcome from './welcome'; const messages = defineMessages({ blockMessage: { id: 'chat_settings.block.message', defaultMessage: 'Blocking will prevent this profile from direct messaging you and viewing your content. You can unblock later.' }, @@ -42,7 +41,6 @@ const messages = defineMessages({ const ChatPageMain = () => { const dispatch = useAppDispatch(); const intl = useIntl(); - const account = useOwnAccount(); const inputRef = useRef(null); @@ -83,12 +81,6 @@ const ChatPageMain = () => { })); }; - if (!chat && !account?.chats_onboarded) { - return ( - - ); - } - if (!chat) { return ; } diff --git a/app/soapbox/features/chats/components/chat-page/components/welcome.tsx b/app/soapbox/features/chats/components/chat-page/components/welcome.tsx index ff545b825f..b096cf9aba 100644 --- a/app/soapbox/features/chats/components/chat-page/components/welcome.tsx +++ b/app/soapbox/features/chats/components/chat-page/components/welcome.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; +import { defineMessages, useIntl } from 'react-intl'; import List, { ListItem } from 'soapbox/components/list'; -import { Button, CardBody, CardTitle, Form, Stack, Toggle } from 'soapbox/components/ui'; +import { Button, CardBody, CardTitle, Form, Stack, Text, Toggle } from 'soapbox/components/ui'; import { useOwnAccount } from 'soapbox/hooks'; import { useUpdateCredentials } from 'soapbox/queries/accounts'; @@ -10,8 +11,18 @@ type FormData = { chats_onboarded: boolean } +const messages = defineMessages({ + title: { id: 'chat.welcome.title', defaultMessage: 'Welcome to {br} Direct Messages!' }, + subtitle: { id: 'chat.welcome.subtitle', defaultMessage: 'By default, all messages are automatically deleted after 14 days for your security.' }, + acceptingMessageLabel: { id: 'chat.welcome.accepting_messages.label', defaultMessage: 'Allow others to message me' }, + acceptingMessageHint: { id: 'chat.welcome.accepting_messages.hint', defaultMessage: 'Only people I follow can send me messages' }, + notice: { id: 'chat.welcome.notice', defaultMessage: 'You can change these settings later.' }, + submit: { id: 'chat.welcome.submit', defaultMessage: 'Save & Continue' }, +}); + const Welcome = () => { const account = useOwnAccount(); + const intl = useIntl(); const updateCredentials = useUpdateCredentials(); const [data, setData] = useState({ @@ -26,28 +37,48 @@ const Welcome = () => { }; return ( - - + + Chats -
- +
+ + {intl.formatMessage(messages.title, { br:
})} +
- - - - setData((prevData) => ({ ...prevData, accepting_messages: event.target.checked }))} - /> - - - + + {intl.formatMessage(messages.subtitle)} + +
-