Chats: make chat acceptance and deletion feature-gated
This commit is contained in:
parent
4dc0ab2d00
commit
9802257751
|
@ -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<IChatListItemInterface> = ({ 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<IChatListItemInterface> = ({ chat, onClick }) => {
|
|||
</HStack>
|
||||
|
||||
<HStack alignItems='center' space={2}>
|
||||
<div className='text-gray-600 hidden group-hover:block hover:text-gray-100'>
|
||||
{/* TODO: fix nested buttons here */}
|
||||
<DropdownMenuContainer
|
||||
items={menu}
|
||||
src={require('@tabler/icons/dots.svg')}
|
||||
title='Settings'
|
||||
/>
|
||||
</div>
|
||||
{features.chatsDelete && (
|
||||
<div className='text-gray-600 hidden group-hover:block hover:text-gray-100'>
|
||||
{/* TODO: fix nested buttons here */}
|
||||
<DropdownMenuContainer
|
||||
items={menu}
|
||||
src={require('@tabler/icons/dots.svg')}
|
||||
title='Settings'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{chat.last_message && (
|
||||
<>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,16 +180,18 @@ const ChatPageMain = () => {
|
|||
</div>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem
|
||||
as='button'
|
||||
onSelect={handleLeaveChat}
|
||||
className='!px-0 hover:!bg-transparent'
|
||||
>
|
||||
<div className='w-full flex items-center space-x-2 font-bold text-sm text-danger-600 dark:text-danger-500'>
|
||||
<Icon src={require('@tabler/icons/logout.svg')} className='w-5 h-5' />
|
||||
<span>{intl.formatMessage(messages.leaveChat)}</span>
|
||||
</div>
|
||||
</MenuItem>
|
||||
{features.chatsDelete && (
|
||||
<MenuItem
|
||||
as='button'
|
||||
onSelect={handleLeaveChat}
|
||||
className='!px-0 hover:!bg-transparent'
|
||||
>
|
||||
<div className='w-full flex items-center space-x-2 font-bold text-sm text-danger-600 dark:text-danger-500'>
|
||||
<Icon src={require('@tabler/icons/logout.svg')} className='w-5 h-5' />
|
||||
<span>{intl.formatMessage(messages.leaveChat)}</span>
|
||||
</div>
|
||||
</MenuItem>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</MenuList>
|
||||
|
|
|
@ -138,10 +138,12 @@ const ChatSettings = () => {
|
|||
<span>{intl.formatMessage(isBlocking ? messages.unblockUser : messages.blockUser, { acct: chat.account.acct })}</span>
|
||||
</button>
|
||||
|
||||
<button onClick={handleLeaveChat} className='w-full flex items-center space-x-2 font-bold text-sm text-danger-600'>
|
||||
<Icon src={require('@tabler/icons/logout.svg')} className='w-5 h-5' />
|
||||
<span>{intl.formatMessage(messages.leaveChat)}</span>
|
||||
</button>
|
||||
{features.chatsDelete && (
|
||||
<button onClick={handleLeaveChat} className='w-full flex items-center space-x-2 font-bold text-sm text-danger-600'>
|
||||
<Icon src={require('@tabler/icons/logout.svg')} className='w-5 h-5' />
|
||||
<span>{intl.formatMessage(messages.leaveChat)}</span>
|
||||
</button>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
</>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue