diff --git a/app/soapbox/features/chats/components/chat-list-item.tsx b/app/soapbox/features/chats/components/chat-list-item.tsx index e9aa815645..756d7f173d 100644 --- a/app/soapbox/features/chats/components/chat-list-item.tsx +++ b/app/soapbox/features/chats/components/chat-list-item.tsx @@ -3,17 +3,15 @@ import { defineMessages, useIntl } from 'react-intl'; import { openModal } from 'soapbox/actions/modals'; import RelativeTimestamp from 'soapbox/components/relative-timestamp'; -import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; +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 { useAppDispatch } from 'soapbox/hooks'; -import { IChat, IChatSilence, useChatActions, useChatSilence } from 'soapbox/queries/chats'; +import { IChat, useChatActions } from 'soapbox/queries/chats'; import type { Menu } from 'soapbox/components/dropdown_menu'; const messages = defineMessages({ - silenceNotifications: { id: 'chat_settings.silence_notifications', defaultMessage: 'Silence notifications' }, - unsilenceNotifications: { id: 'chat_settings.unsilence_notifications', defaultMessage: 'Unsilence notifications' }, 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' }, @@ -23,57 +21,29 @@ const messages = defineMessages({ interface IChatListItemInterface { chat: IChat, onClick: (chat: any) => void, - chatSilence?: IChatSilence } -const ChatListItem: React.FC = ({ chat, chatSilence, onClick }) => { +const ChatListItem: React.FC = ({ chat, onClick }) => { const dispatch = useAppDispatch(); const intl = useIntl(); - const { handleSilence } = useChatSilence(chat); const { deleteChat } = useChatActions(chat?.id as string); - const menu = useMemo((): Menu => { - const menu: Menu = []; + const menu = useMemo((): Menu => [{ + text: intl.formatMessage(messages.leaveChat), + action: (event) => { + event.stopPropagation(); - if (chatSilence) { - menu.push({ - text: intl.formatMessage(messages.unsilenceNotifications), - action: (event) => { - event.stopPropagation(); - handleSilence(); - }, - icon: require('@tabler/icons/bell.svg'), - }); - } else { - menu.push({ - text: intl.formatMessage(messages.silenceNotifications), - action: (event) => { - event.stopPropagation(); - handleSilence(); - }, - icon: require('@tabler/icons/bell-off.svg'), - }); - } - - menu.push({ - text: intl.formatMessage(messages.leaveChat), - action: (event) => { - event.stopPropagation(); - - dispatch(openModal('CONFIRM', { - heading: intl.formatMessage(messages.leaveHeading), - message: intl.formatMessage(messages.leaveMessage), - confirm: intl.formatMessage(messages.leaveConfirm), - confirmationTheme: 'primary', - onConfirm: () => deleteChat.mutate(), - })); - }, - icon: require('@tabler/icons/logout.svg'), - }); - - return menu; - }, [chatSilence]); + dispatch(openModal('CONFIRM', { + heading: intl.formatMessage(messages.leaveHeading), + message: intl.formatMessage(messages.leaveMessage), + confirm: intl.formatMessage(messages.leaveConfirm), + confirmationTheme: 'primary', + onConfirm: () => deleteChat.mutate(), + })); + }, + icon: require('@tabler/icons/logout.svg'), + }], []); return ( // eslint-disable-next-line jsx-a11y/interactive-supports-focus @@ -119,11 +89,6 @@ const ChatListItem: React.FC = ({ chat, chatSilence, onC /> - - {chatSilence ? ( - - ) : null} - {chat.last_message && ( <> {chat.last_message.unread && ( diff --git a/app/soapbox/features/chats/components/chat-list.tsx b/app/soapbox/features/chats/components/chat-list.tsx index 40834e9530..c4d312d2a4 100644 --- a/app/soapbox/features/chats/components/chat-list.tsx +++ b/app/soapbox/features/chats/components/chat-list.tsx @@ -8,7 +8,7 @@ import PullToRefresh from 'soapbox/components/pull-to-refresh'; import { Spinner, Stack, Text } from 'soapbox/components/ui'; import PlaceholderChat from 'soapbox/features/placeholder/components/placeholder-chat'; import { useAppDispatch } from 'soapbox/hooks'; -import { useChats, useChatSilences } from 'soapbox/queries/chats'; +import { useChats } from 'soapbox/queries/chats'; import ChatListItem from './chat-list-item'; @@ -25,8 +25,6 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false, s const { chatsQuery: { data: chats, isFetching, hasNextPage, fetchNextPage } } = useChats(searchValue); - const { data: chatSilences } = useChatSilences(); - const [isNearBottom, setNearBottom] = useState(false); const [isNearTop, setNearTop] = useState(true); @@ -78,14 +76,12 @@ const ChatList: React.FC = ({ onClickChat, useWindowScroll = false, s useWindowScroll={useWindowScroll} data={chats} endReached={handleLoadMore} - itemContent={(_index, chat) => { - const chatSilence = chatSilences?.find((chatSilence) => String(chatSilence.target_account_id) === chat.account.id); - return ( -
- -
- ); - }} + itemContent={(_index, chat) => ( +
+ +
+ ) + } components={{ ScrollSeekPlaceholder: () => , Footer: () => hasNextPage ? : null, 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 eef4725c38..1e12d8ba22 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 @@ -1,14 +1,13 @@ -import React, { useEffect, useRef } from 'react'; +import React, { useRef } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { blockAccount } from 'soapbox/actions/accounts'; import { openModal } from 'soapbox/actions/modals'; -import List, { ListItem } from 'soapbox/components/list'; -import { Avatar, Divider, HStack, Icon, IconButton, Menu, MenuButton, MenuItem, MenuList, Stack, Text, Toggle } from 'soapbox/components/ui'; +import { Avatar, Divider, 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, useOwnAccount } from 'soapbox/hooks'; -import { useChatActions, useChatSilence } from 'soapbox/queries/chats'; +import { useChatActions } from 'soapbox/queries/chats'; import Chat from '../../chat'; @@ -32,10 +31,9 @@ const ChatPageMain = () => { const intl = useIntl(); const account = useOwnAccount(); - const inputRef = useRef(null); + const inputRef = useRef(null); const { chat, setChat } = useChatContext(); - const { isSilenced, handleSilence, fetchChatSilence } = useChatSilence(chat); const { deleteChat } = useChatActions(chat?.id as string); const handleBlockUser = () => { @@ -58,12 +56,6 @@ const ChatPageMain = () => { })); }; - useEffect(() => { - if (chat?.id) { - fetchChatSilence(); - } - }, [chat?.id]); - if (!chat && !account?.chats_onboarded) { return ( @@ -127,14 +119,6 @@ const ChatPageMain = () => { - - - - - - - - { const intl = useIntl(); const { chat, setEditing, toggleChatPane } = useChatContext(); - const { isSilenced, handleSilence, fetchChatSilence } = useChatSilence(chat); - const { deleteChat } = useChatActions(chat?.id as string); const closeSettings = () => setEditing(false); @@ -59,12 +56,6 @@ const ChatSettings = () => { })); }; - useEffect(() => { - if (chat?.id) { - fetchChatSilence(); - } - }, [chat?.id]); - if (!chat) { return null; } @@ -102,14 +93,6 @@ const ChatSettings = () => { - - - - - - - -