Chats: make chatsExpiration a conditional feature

environments/review-chats-g56n7m/deployments/1250
Alex Gleason 2 years ago
parent 239b2af553
commit 69d92b6f95
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -7,7 +7,7 @@ import List, { ListItem } from 'soapbox/components/list';
import { Avatar, HStack, Icon, IconButton, Menu, MenuButton, MenuItem, MenuList, Stack, Text } from 'soapbox/components/ui'; import { Avatar, HStack, Icon, IconButton, Menu, MenuButton, MenuItem, MenuList, Stack, Text } from 'soapbox/components/ui';
import VerificationBadge from 'soapbox/components/verification_badge'; import VerificationBadge from 'soapbox/components/verification_badge';
import { useChatContext } from 'soapbox/contexts/chat-context'; import { useChatContext } from 'soapbox/contexts/chat-context';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
import { MessageExpirationValues, useChatActions } from 'soapbox/queries/chats'; import { MessageExpirationValues, useChatActions } from 'soapbox/queries/chats';
import { secondsToDays } from 'soapbox/utils/numbers'; import { secondsToDays } from 'soapbox/utils/numbers';
@ -41,6 +41,7 @@ const messages = defineMessages({
const ChatPageMain = () => { const ChatPageMain = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const intl = useIntl(); const intl = useIntl();
const features = useFeatures();
const inputRef = useRef<HTMLTextAreaElement | null>(null); const inputRef = useRef<HTMLTextAreaElement | null>(null);
@ -138,6 +139,7 @@ const ChatPageMain = () => {
</Stack> </Stack>
</HStack> </HStack>
{features.chatsExpiration && (
<List> <List>
<ListItem <ListItem
label={intl.formatMessage(messages.autoDeleteLabel)} label={intl.formatMessage(messages.autoDeleteLabel)}
@ -164,6 +166,7 @@ const ChatPageMain = () => {
isSelected={chat.message_expiration === MessageExpirationValues.NINETY} isSelected={chat.message_expiration === MessageExpirationValues.NINETY}
/> />
</List> </List>
)}
<Stack space={2}> <Stack space={2}>
<MenuItem <MenuItem

@ -6,7 +6,7 @@ import { openModal } from 'soapbox/actions/modals';
import List, { ListItem } from 'soapbox/components/list'; import List, { ListItem } from 'soapbox/components/list';
import { Avatar, HStack, Icon, Select, Stack, Text } from 'soapbox/components/ui'; import { Avatar, HStack, Icon, Select, Stack, Text } from 'soapbox/components/ui';
import { useChatContext } from 'soapbox/contexts/chat-context'; import { useChatContext } from 'soapbox/contexts/chat-context';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
import { messageExpirationOptions, MessageExpirationValues, useChatActions } from 'soapbox/queries/chats'; import { messageExpirationOptions, MessageExpirationValues, useChatActions } from 'soapbox/queries/chats';
import { secondsToDays } from 'soapbox/utils/numbers'; import { secondsToDays } from 'soapbox/utils/numbers';
@ -33,6 +33,7 @@ const messages = defineMessages({
const ChatSettings = () => { const ChatSettings = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const intl = useIntl(); const intl = useIntl();
const features = useFeatures();
const { chat, setEditing, toggleChatPane } = useChatContext(); const { chat, setEditing, toggleChatPane } = useChatContext();
const { deleteChat, updateChat } = useChatActions(chat?.id as string); const { deleteChat, updateChat } = useChatActions(chat?.id as string);
@ -113,6 +114,7 @@ const ChatSettings = () => {
</Stack> </Stack>
</HStack> </HStack>
{features.chatsExpiration && (
<List> <List>
<ListItem label={intl.formatMessage(messages.autoDeleteLabel)}> <ListItem label={intl.formatMessage(messages.autoDeleteLabel)}>
<Select defaultValue={chat.message_expiration} onChange={(event) => handleUpdateChat(Number(event.target.value))}> <Select defaultValue={chat.message_expiration} onChange={(event) => handleUpdateChat(Number(event.target.value))}>
@ -128,6 +130,7 @@ const ChatSettings = () => {
</Select> </Select>
</ListItem> </ListItem>
</List> </List>
)}
<Stack space={5}> <Stack space={5}>
<button onClick={isBlocking ? handleUnblockUser : handleBlockUser} className='w-full flex items-center space-x-2 font-bold text-sm text-primary-600 dark:text-accent-blue'> <button onClick={isBlocking ? handleUnblockUser : handleBlockUser} className='w-full flex items-center space-x-2 font-bold text-sm text-primary-600 dark:text-accent-blue'>

@ -204,6 +204,12 @@ const getInstanceFeatures = (instance: Instance) => {
*/ */
chats: v.software === TRUTHSOCIAL || (v.software === PLEROMA && gte(v.version, '2.1.0')), chats: v.software === TRUTHSOCIAL || (v.software === PLEROMA && gte(v.version, '2.1.0')),
/**
* Ability to set disappearing messages on chats.
* @see PATCH /api/v1/pleroma/chats/:id
*/
chatsExpiration: v.software === TRUTHSOCIAL,
/** /**
* Ability to search among chats. * Ability to search among chats.
* @see GET /api/v1/pleroma/chats * @see GET /api/v1/pleroma/chats

Loading…
Cancel
Save