sforkowany z mirror/soapbox
Chats: feature-gate chat message reporting
rodzic
4d9f7fec32
commit
1873ba3e22
|
@ -3,6 +3,7 @@ import React from 'react';
|
|||
import { VirtuosoMockContext } from 'react-virtuoso';
|
||||
|
||||
import { ChatContext } from 'soapbox/contexts/chat-context';
|
||||
import { normalizeInstance } from 'soapbox/normalizers';
|
||||
import { IAccount } from 'soapbox/queries/accounts';
|
||||
|
||||
import { __stub } from '../../../../api';
|
||||
|
@ -52,7 +53,9 @@ Object.assign(navigator, {
|
|||
},
|
||||
});
|
||||
|
||||
const store = rootState.set('me', '1');
|
||||
const store = rootState
|
||||
.set('me', '1')
|
||||
.set('instance', normalizeInstance({ version: '3.4.1 (compatible; TruthSocial 1.0.0)' }));
|
||||
|
||||
const renderComponentWithChatContext = () => render(
|
||||
<VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
||||
|
|
|
@ -14,7 +14,7 @@ import DropdownMenuContainer from 'soapbox/containers/dropdown_menu_container';
|
|||
import PlaceholderChatMessage from 'soapbox/features/placeholder/components/placeholder-chat-message';
|
||||
import Bundle from 'soapbox/features/ui/components/bundle';
|
||||
import { MediaGallery } from 'soapbox/features/ui/util/async-components';
|
||||
import { useAppSelector, useAppDispatch, useOwnAccount } from 'soapbox/hooks';
|
||||
import { useAppSelector, useAppDispatch, useOwnAccount, useFeatures } from 'soapbox/hooks';
|
||||
import { normalizeAccount } from 'soapbox/normalizers';
|
||||
import { ChatKeys, IChat, IChatMessage, useChatActions, useChatMessages } from 'soapbox/queries/chats';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
|
@ -73,6 +73,7 @@ const ChatMessageList: React.FC<IChatMessageList> = ({ chat, autosize }) => {
|
|||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
const account = useOwnAccount();
|
||||
const features = useFeatures();
|
||||
|
||||
const node = useRef<VirtuosoHandle>(null);
|
||||
const [firstItemIndex, setFirstItemIndex] = useState(START_INDEX - 20);
|
||||
|
@ -239,11 +240,13 @@ const ChatMessageList: React.FC<IChatMessageList> = ({ chat, autosize }) => {
|
|||
destructive: true,
|
||||
});
|
||||
} else {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.report),
|
||||
action: () => dispatch(initReport(normalizeAccount(chat.account) as any, { chatMessage })),
|
||||
icon: require('@tabler/icons/flag.svg'),
|
||||
});
|
||||
if (features.reportChats) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.report),
|
||||
action: () => dispatch(initReport(normalizeAccount(chat.account) as any, { chatMessage })),
|
||||
icon: require('@tabler/icons/flag.svg'),
|
||||
});
|
||||
}
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.deleteForMe),
|
||||
action: () => handleDeleteMessage.mutate(chatMessage.id),
|
||||
|
|
|
@ -532,10 +532,17 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === PLEROMA && v.build === SOAPBOX && gte(v.version, '2.4.50'),
|
||||
]),
|
||||
|
||||
reportMultipleStatuses: any([
|
||||
v.software === MASTODON,
|
||||
v.software === PLEROMA,
|
||||
]),
|
||||
/**
|
||||
* Ability to report chat messages.
|
||||
* @see POST /api/v1/reports
|
||||
*/
|
||||
reportChats: v.software === TRUTHSOCIAL,
|
||||
|
||||
/**
|
||||
* Ability to select more than one status when reporting.
|
||||
* @see POST /api/v1/reports
|
||||
*/
|
||||
reportMultipleStatuses: v.software !== TRUTHSOCIAL,
|
||||
|
||||
/**
|
||||
* Can request a password reset email through the API.
|
||||
|
|
Ładowanie…
Reference in New Issue