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 VerificationBadge from 'soapbox/components/verification_badge';
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 { secondsToDays } from 'soapbox/utils/numbers';
@ -41,6 +41,7 @@ const messages = defineMessages({
const ChatPageMain = () => {
const dispatch = useAppDispatch();
const intl = useIntl();
const features = useFeatures();
const inputRef = useRef<HTMLTextAreaElement | null>(null);
@ -138,6 +139,7 @@ const ChatPageMain = () => {
</Stack>
</HStack>
{features.chatsExpiration && (
<List>
<ListItem
label={intl.formatMessage(messages.autoDeleteLabel)}
@ -164,6 +166,7 @@ const ChatPageMain = () => {
isSelected={chat.message_expiration === MessageExpirationValues.NINETY}
/>
</List>
)}
<Stack space={2}>
<MenuItem

@ -6,7 +6,7 @@ import { openModal } from 'soapbox/actions/modals';
import List, { ListItem } from 'soapbox/components/list';
import { Avatar, HStack, Icon, Select, Stack, Text } from 'soapbox/components/ui';
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 { secondsToDays } from 'soapbox/utils/numbers';
@ -33,6 +33,7 @@ const messages = defineMessages({
const ChatSettings = () => {
const dispatch = useAppDispatch();
const intl = useIntl();
const features = useFeatures();
const { chat, setEditing, toggleChatPane } = useChatContext();
const { deleteChat, updateChat } = useChatActions(chat?.id as string);
@ -113,6 +114,7 @@ const ChatSettings = () => {
</Stack>
</HStack>
{features.chatsExpiration && (
<List>
<ListItem label={intl.formatMessage(messages.autoDeleteLabel)}>
<Select defaultValue={chat.message_expiration} onChange={(event) => handleUpdateChat(Number(event.target.value))}>
@ -128,6 +130,7 @@ const ChatSettings = () => {
</Select>
</ListItem>
</List>
)}
<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'>

@ -204,6 +204,12 @@ const getInstanceFeatures = (instance: Instance) => {
*/
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.
* @see GET /api/v1/pleroma/chats

Loading…
Cancel
Save