From 14353c1aff8ea1d35d2d61b723b6c8514d00b4a3 Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Mon, 7 Nov 2022 11:16:47 -0500 Subject: [PATCH] Add blocked copy in ChatList --- .../chats/components/chat-list-item.tsx | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/soapbox/features/chats/components/chat-list-item.tsx b/app/soapbox/features/chats/components/chat-list-item.tsx index 5937800cf..014e6f88c 100644 --- a/app/soapbox/features/chats/components/chat-list-item.tsx +++ b/app/soapbox/features/chats/components/chat-list-item.tsx @@ -8,12 +8,13 @@ import { Avatar, HStack, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification_badge'; import DropdownMenuContainer from 'soapbox/containers/dropdown_menu_container'; import { useChatContext } from 'soapbox/contexts/chat-context'; -import { useAppDispatch, useFeatures } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { IChat, useChatActions } from 'soapbox/queries/chats'; import type { Menu } from 'soapbox/components/dropdown_menu'; const messages = defineMessages({ + blockedYou: { id: 'chat_list_item.blocked_you', defaultMessage: 'This user has blocked you' }, leaveMessage: { id: 'chat_settings.leave.message', defaultMessage: 'Are you sure you want to leave this chat? Messages will be deleted for you and this chat will be removed from your inbox.' }, leaveHeading: { id: 'chat_settings.leave.heading', defaultMessage: 'Leave Chat' }, leaveConfirm: { id: 'chat_settings.leave.confirm', defaultMessage: 'Leave Chat' }, @@ -33,6 +34,7 @@ const ChatListItem: React.FC = ({ chat, onClick }) => { const { isUsingMainChatPage } = useChatContext(); const { deleteChat } = useChatActions(chat?.id as string); + const isBlocked = useAppSelector((state) => state.getIn(['relationships', chat.account.id, 'blocked_by'])); const menu = useMemo((): Menu => [{ text: intl.formatMessage(messages.leaveChat), @@ -77,17 +79,33 @@ const ChatListItem: React.FC = ({ chat, onClick }) => { {chat.account?.verified && } - {chat.last_message?.content && ( + {isBlocked ? ( + > + {intl.formatMessage(messages.blockedYou)} + + ) : ( + <> + {chat.last_message?.content && ( + + )} + )}