diff --git a/app/soapbox/features/chats/components/chat-list-item.tsx b/app/soapbox/features/chats/components/chat-list-item.tsx index 756d7f173..7b2a229a2 100644 --- a/app/soapbox/features/chats/components/chat-list-item.tsx +++ b/app/soapbox/features/chats/components/chat-list-item.tsx @@ -6,7 +6,7 @@ import RelativeTimestamp from 'soapbox/components/relative-timestamp'; 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 { useAppDispatch, useFeatures } from 'soapbox/hooks'; import { IChat, useChatActions } from 'soapbox/queries/chats'; import type { Menu } from 'soapbox/components/dropdown_menu'; @@ -26,6 +26,7 @@ interface IChatListItemInterface { const ChatListItem: React.FC = ({ chat, onClick }) => { const dispatch = useAppDispatch(); const intl = useIntl(); + const features = useFeatures(); const { deleteChat } = useChatActions(chat?.id as string); @@ -80,14 +81,16 @@ const ChatListItem: React.FC = ({ chat, onClick }) => { -
- {/* TODO: fix nested buttons here */} - -
+ {features.chatsDelete && ( +
+ {/* TODO: fix nested buttons here */} + +
+ )} {chat.last_message && ( <> diff --git a/app/soapbox/features/chats/components/chat-message-list-intro.tsx b/app/soapbox/features/chats/components/chat-message-list-intro.tsx index 19efe998c..2386f24f4 100644 --- a/app/soapbox/features/chats/components/chat-message-list-intro.tsx +++ b/app/soapbox/features/chats/components/chat-message-list-intro.tsx @@ -6,7 +6,7 @@ import { openModal } from 'soapbox/actions/modals'; import Link from 'soapbox/components/link'; import { Avatar, Button, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; import { useChatContext } from 'soapbox/contexts/chat-context'; -import { useAppDispatch } from 'soapbox/hooks'; +import { useAppDispatch, useFeatures } from 'soapbox/hooks'; import { useChatActions } from 'soapbox/queries/chats'; import { secondsToDays } from 'soapbox/utils/numbers'; @@ -24,6 +24,7 @@ const messages = defineMessages({ const ChatMessageListIntro = () => { const dispatch = useAppDispatch(); const intl = useIntl(); + const features = useFeatures(); const { chat, needsAcceptance } = useChatContext(); const { acceptChat, deleteChat } = useChatActions(chat?.id as string); @@ -38,7 +39,7 @@ const ChatMessageListIntro = () => { })); }; - if (!chat) { + if (!chat || !features.chatAcceptance) { return 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 c4bc06105..44dd164c6 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 @@ -180,16 +180,18 @@ const ChatPageMain = () => { - -
- - {intl.formatMessage(messages.leaveChat)} -
-
+ {features.chatsDelete && ( + +
+ + {intl.formatMessage(messages.leaveChat)} +
+
+ )} diff --git a/app/soapbox/features/chats/components/chat-widget/chat-settings.tsx b/app/soapbox/features/chats/components/chat-widget/chat-settings.tsx index 9355108fd..a138332e2 100644 --- a/app/soapbox/features/chats/components/chat-widget/chat-settings.tsx +++ b/app/soapbox/features/chats/components/chat-widget/chat-settings.tsx @@ -138,10 +138,12 @@ const ChatSettings = () => { {intl.formatMessage(isBlocking ? messages.unblockUser : messages.blockUser, { acct: chat.account.acct })} - + {features.chatsDelete && ( + + )} diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 2a8e002b1..7badea639 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -198,12 +198,24 @@ const getInstanceFeatures = (instance: Instance) => { v.software === PLEROMA, ]), + /** + * Ability to accept a chat. + * POST /api/v1/pleroma/chats/:id/accept + */ + chatAcceptance: v.software === TRUTHSOCIAL, + /** * Pleroma chats API. * @see {@link https://docs.pleroma.social/backend/development/API/chats/} */ chats: v.software === TRUTHSOCIAL || (v.software === PLEROMA && gte(v.version, '2.1.0')), + /** + * Ability to delete a chat. + * @see DELETE /api/v1/pleroma/chats/:id + */ + chatsDelete: v.software === TRUTHSOCIAL, + /** * Ability to set disappearing messages on chats. * @see PATCH /api/v1/pleroma/chats/:id