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 { VirtuosoMockContext } from 'react-virtuoso';
|
||||||
|
|
||||||
import { ChatContext } from 'soapbox/contexts/chat-context';
|
import { ChatContext } from 'soapbox/contexts/chat-context';
|
||||||
|
import { normalizeInstance } from 'soapbox/normalizers';
|
||||||
import { IAccount } from 'soapbox/queries/accounts';
|
import { IAccount } from 'soapbox/queries/accounts';
|
||||||
|
|
||||||
import { __stub } from '../../../../api';
|
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(
|
const renderComponentWithChatContext = () => render(
|
||||||
<VirtuosoMockContext.Provider value={{ viewportHeight: 300, itemHeight: 100 }}>
|
<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 PlaceholderChatMessage from 'soapbox/features/placeholder/components/placeholder-chat-message';
|
||||||
import Bundle from 'soapbox/features/ui/components/bundle';
|
import Bundle from 'soapbox/features/ui/components/bundle';
|
||||||
import { MediaGallery } from 'soapbox/features/ui/util/async-components';
|
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 { normalizeAccount } from 'soapbox/normalizers';
|
||||||
import { ChatKeys, IChat, IChatMessage, useChatActions, useChatMessages } from 'soapbox/queries/chats';
|
import { ChatKeys, IChat, IChatMessage, useChatActions, useChatMessages } from 'soapbox/queries/chats';
|
||||||
import { queryClient } from 'soapbox/queries/client';
|
import { queryClient } from 'soapbox/queries/client';
|
||||||
|
@ -73,6 +73,7 @@ const ChatMessageList: React.FC<IChatMessageList> = ({ chat, autosize }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const account = useOwnAccount();
|
const account = useOwnAccount();
|
||||||
|
const features = useFeatures();
|
||||||
|
|
||||||
const node = useRef<VirtuosoHandle>(null);
|
const node = useRef<VirtuosoHandle>(null);
|
||||||
const [firstItemIndex, setFirstItemIndex] = useState(START_INDEX - 20);
|
const [firstItemIndex, setFirstItemIndex] = useState(START_INDEX - 20);
|
||||||
|
@ -239,11 +240,13 @@ const ChatMessageList: React.FC<IChatMessageList> = ({ chat, autosize }) => {
|
||||||
destructive: true,
|
destructive: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
menu.push({
|
if (features.reportChats) {
|
||||||
text: intl.formatMessage(messages.report),
|
menu.push({
|
||||||
action: () => dispatch(initReport(normalizeAccount(chat.account) as any, { chatMessage })),
|
text: intl.formatMessage(messages.report),
|
||||||
icon: require('@tabler/icons/flag.svg'),
|
action: () => dispatch(initReport(normalizeAccount(chat.account) as any, { chatMessage })),
|
||||||
});
|
icon: require('@tabler/icons/flag.svg'),
|
||||||
|
});
|
||||||
|
}
|
||||||
menu.push({
|
menu.push({
|
||||||
text: intl.formatMessage(messages.deleteForMe),
|
text: intl.formatMessage(messages.deleteForMe),
|
||||||
action: () => handleDeleteMessage.mutate(chatMessage.id),
|
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'),
|
v.software === PLEROMA && v.build === SOAPBOX && gte(v.version, '2.4.50'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
reportMultipleStatuses: any([
|
/**
|
||||||
v.software === MASTODON,
|
* Ability to report chat messages.
|
||||||
v.software === PLEROMA,
|
* @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.
|
* Can request a password reset email through the API.
|
||||||
|
|
Ładowanie…
Reference in New Issue