Moves blockAndReportSpam to redux
This commit is contained in:
parent
92a512a16d
commit
105162dc66
26 changed files with 282 additions and 324 deletions
|
@ -96,11 +96,10 @@ const useProps = (overrideProps: Partial<Props> = {}): Props => ({
|
|||
clearShowPickerHint: action('clearShowPickerHint'),
|
||||
// Message Requests
|
||||
conversationType: 'direct',
|
||||
onAccept: action('onAccept'),
|
||||
onBlock: action('onBlock'),
|
||||
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
||||
onDelete: action('onDelete'),
|
||||
onUnblock: action('onUnblock'),
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockConversation: action('blockConversation'),
|
||||
blockAndReportSpam: action('blockAndReportSpam'),
|
||||
deleteConversation: action('deleteConversation'),
|
||||
messageRequestsEnabled: boolean(
|
||||
'messageRequestsEnabled',
|
||||
overrideProps.messageRequestsEnabled || false
|
||||
|
|
|
@ -240,11 +240,10 @@ export function CompositionArea({
|
|||
isMissingMandatoryProfileSharing,
|
||||
left,
|
||||
messageRequestsEnabled,
|
||||
onAccept,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onDelete,
|
||||
onUnblock,
|
||||
acceptConversation,
|
||||
blockConversation,
|
||||
blockAndReportSpam,
|
||||
deleteConversation,
|
||||
title,
|
||||
// GroupV1 Disabled Actions
|
||||
isGroupV1AndDisabled,
|
||||
|
@ -497,14 +496,14 @@ export function CompositionArea({
|
|||
) {
|
||||
return (
|
||||
<MessageRequestActions
|
||||
i18n={i18n}
|
||||
acceptConversation={acceptConversation}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
blockConversation={blockConversation}
|
||||
conversationId={conversationId}
|
||||
conversationType={conversationType}
|
||||
deleteConversation={deleteConversation}
|
||||
i18n={i18n}
|
||||
isBlocked={isBlocked}
|
||||
onBlock={onBlock}
|
||||
onBlockAndReportSpam={onBlockAndReportSpam}
|
||||
onUnblock={onUnblock}
|
||||
onDelete={onDelete}
|
||||
onAccept={onAccept}
|
||||
title={title}
|
||||
/>
|
||||
);
|
||||
|
@ -549,12 +548,13 @@ export function CompositionArea({
|
|||
) {
|
||||
return (
|
||||
<MandatoryProfileSharingActions
|
||||
i18n={i18n}
|
||||
acceptConversation={acceptConversation}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
blockConversation={blockConversation}
|
||||
conversationId={conversationId}
|
||||
conversationType={conversationType}
|
||||
onBlock={onBlock}
|
||||
onBlockAndReportSpam={onBlockAndReportSpam}
|
||||
onDelete={onDelete}
|
||||
onAccept={onAccept}
|
||||
deleteConversation={deleteConversation}
|
||||
i18n={i18n}
|
||||
title={title}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -80,3 +80,10 @@ StoryVideoError.args = {
|
|||
toastType: ToastType.StoryVideoError,
|
||||
},
|
||||
};
|
||||
|
||||
export const ReportedSpamAndBlocked = Template.bind({});
|
||||
ReportedSpamAndBlocked.args = {
|
||||
toast: {
|
||||
toastType: ToastType.ReportedSpamAndBlocked,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -97,6 +97,14 @@ export function ToastManager({
|
|||
return <ToastMessageBodyTooLong i18n={i18n} onClose={hideToast} />;
|
||||
}
|
||||
|
||||
if (toastType === ToastType.ReportedSpamAndBlocked) {
|
||||
return (
|
||||
<Toast onClose={hideToast}>
|
||||
{i18n('MessageRequests--block-and-report-spam-success-toast')}
|
||||
</Toast>
|
||||
);
|
||||
}
|
||||
|
||||
if (toastType === ToastType.StoryMuted) {
|
||||
return (
|
||||
<Toast onClose={hideToast} timeout={SHORT_TIMEOUT}>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { ToastReportedSpamAndBlocked } from './ToastReportedSpamAndBlocked';
|
||||
|
||||
import { setupI18n } from '../util/setupI18n';
|
||||
import enMessages from '../../_locales/en/messages.json';
|
||||
|
||||
const i18n = setupI18n('en', enMessages);
|
||||
|
||||
const defaultProps = {
|
||||
i18n,
|
||||
onClose: action('onClose'),
|
||||
};
|
||||
|
||||
export default {
|
||||
title: 'Components/ToastReportedSpamAndBlocked',
|
||||
};
|
||||
|
||||
export const _ToastReportedSpamAndBlocked = (): JSX.Element => (
|
||||
<ToastReportedSpamAndBlocked {...defaultProps} />
|
||||
);
|
||||
|
||||
_ToastReportedSpamAndBlocked.story = {
|
||||
name: 'ToastReportedSpamAndBlocked',
|
||||
};
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import type { LocalizerType } from '../types/Util';
|
||||
import { Toast } from './Toast';
|
||||
|
||||
type PropsType = {
|
||||
i18n: LocalizerType;
|
||||
onClose: () => unknown;
|
||||
};
|
||||
|
||||
export function ToastReportedSpamAndBlocked({
|
||||
i18n,
|
||||
onClose,
|
||||
}: PropsType): JSX.Element {
|
||||
return (
|
||||
<Toast onClose={onClose}>
|
||||
{i18n('MessageRequests--block-and-report-spam-success-toast')}
|
||||
</Toast>
|
||||
);
|
||||
}
|
|
@ -19,15 +19,15 @@ export default {
|
|||
};
|
||||
|
||||
const getCommonProps = () => ({
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockAndReportSpam: action('blockAndReportSpam'),
|
||||
blockConversation: action('blockConversation'),
|
||||
deleteConversation: action('deleteConversation'),
|
||||
getPreferredBadge: () => undefined,
|
||||
i18n,
|
||||
groupConversationId: 'convo-id',
|
||||
onBlock: action('onBlock'),
|
||||
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
||||
i18n,
|
||||
onClose: action('onClose'),
|
||||
onDelete: action('onDelete'),
|
||||
onShowContactModal: action('onShowContactModal'),
|
||||
onUnblock: action('onUnblock'),
|
||||
removeMember: action('removeMember'),
|
||||
theme: ThemeType.light,
|
||||
});
|
||||
|
|
|
@ -25,14 +25,14 @@ import { missingCaseError } from '../../util/missingCaseError';
|
|||
import { isInSystemContacts } from '../../util/isInSystemContacts';
|
||||
|
||||
export type PropsType = {
|
||||
acceptConversation: (conversationId: string) => unknown;
|
||||
blockAndReportSpam: (conversationId: string) => unknown;
|
||||
blockConversation: (conversationId: string) => unknown;
|
||||
deleteConversation: (conversationId: string) => unknown;
|
||||
getPreferredBadge: PreferredBadgeSelectorType;
|
||||
i18n: LocalizerType;
|
||||
onBlock: (conversationId: string) => unknown;
|
||||
onBlockAndReportSpam: (conversationId: string) => unknown;
|
||||
onClose: () => void;
|
||||
onDelete: (conversationId: string) => unknown;
|
||||
onShowContactModal: (contactId: string, conversationId?: string) => unknown;
|
||||
onUnblock: (conversationId: string) => unknown;
|
||||
removeMember: (conversationId: string) => unknown;
|
||||
theme: ThemeType;
|
||||
} & (
|
||||
|
@ -62,14 +62,14 @@ enum ConfirmationStateType {
|
|||
|
||||
export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element {
|
||||
const {
|
||||
acceptConversation,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
deleteConversation,
|
||||
getPreferredBadge,
|
||||
i18n,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onClose,
|
||||
onDelete,
|
||||
onShowContactModal,
|
||||
onUnblock,
|
||||
removeMember,
|
||||
theme,
|
||||
} = props;
|
||||
|
@ -96,21 +96,14 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element {
|
|||
case ConfirmationStateType.ConfirmingBlock:
|
||||
return (
|
||||
<MessageRequestActionsConfirmation
|
||||
i18n={i18n}
|
||||
onBlock={() => {
|
||||
onBlock(affectedConversation.id);
|
||||
}}
|
||||
onBlockAndReportSpam={() => {
|
||||
onBlockAndReportSpam(affectedConversation.id);
|
||||
}}
|
||||
onUnblock={() => {
|
||||
onUnblock(affectedConversation.id);
|
||||
}}
|
||||
onDelete={() => {
|
||||
onDelete(affectedConversation.id);
|
||||
}}
|
||||
title={affectedConversation.title}
|
||||
acceptConversation={acceptConversation}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
blockConversation={blockConversation}
|
||||
conversationId={affectedConversation.id}
|
||||
conversationType="direct"
|
||||
deleteConversation={deleteConversation}
|
||||
i18n={i18n}
|
||||
title={affectedConversation.title}
|
||||
state={
|
||||
type === ConfirmationStateType.ConfirmingDelete
|
||||
? MessageRequestState.deleting
|
||||
|
@ -279,7 +272,7 @@ export function ContactSpoofingReviewDialog(props: PropsType): JSX.Element {
|
|||
<Button
|
||||
variant={ButtonVariant.SecondaryAffirmative}
|
||||
onClick={() => {
|
||||
onUnblock(conversationInfo.conversation.id);
|
||||
acceptConversation(conversationInfo.conversation.id);
|
||||
}}
|
||||
>
|
||||
{i18n('MessageRequests--unblock')}
|
||||
|
|
|
@ -15,16 +15,17 @@ const i18n = setupI18n('en', enMessages);
|
|||
const getBaseProps = (
|
||||
isGroup = false
|
||||
): MandatoryProfileSharingActionsProps => ({
|
||||
conversationId: '123',
|
||||
i18n,
|
||||
conversationType: isGroup ? 'group' : 'direct',
|
||||
firstName: text('firstName', 'Cayce'),
|
||||
title: isGroup
|
||||
? text('title', 'NYC Rock Climbers')
|
||||
: text('title', 'Cayce Bollard'),
|
||||
onBlock: action('block'),
|
||||
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
||||
onDelete: action('delete'),
|
||||
onAccept: action('accept'),
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockAndReportSpam: action('blockAndReportSpam'),
|
||||
blockConversation: action('blockConversation'),
|
||||
deleteConversation: action('deleteConversation'),
|
||||
});
|
||||
|
||||
export default {
|
||||
|
|
|
@ -16,21 +16,26 @@ import type { LocalizerType } from '../../types/Util';
|
|||
export type Props = {
|
||||
i18n: LocalizerType;
|
||||
firstName?: string;
|
||||
onAccept(): unknown;
|
||||
} & Omit<ContactNameProps, 'module'> &
|
||||
Pick<
|
||||
MessageRequestActionsConfirmationProps,
|
||||
'conversationType' | 'onBlock' | 'onBlockAndReportSpam' | 'onDelete'
|
||||
| 'acceptConversation'
|
||||
| 'blockAndReportSpam'
|
||||
| 'blockConversation'
|
||||
| 'conversationId'
|
||||
| 'conversationType'
|
||||
| 'deleteConversation'
|
||||
>;
|
||||
|
||||
export function MandatoryProfileSharingActions({
|
||||
acceptConversation,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
conversationId,
|
||||
conversationType,
|
||||
deleteConversation,
|
||||
firstName,
|
||||
i18n,
|
||||
onAccept,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onDelete,
|
||||
title,
|
||||
}: Props): JSX.Element {
|
||||
const [mrState, setMrState] = React.useState(MessageRequestState.default);
|
||||
|
@ -39,15 +44,16 @@ export function MandatoryProfileSharingActions({
|
|||
<>
|
||||
{mrState !== MessageRequestState.default ? (
|
||||
<MessageRequestActionsConfirmation
|
||||
i18n={i18n}
|
||||
onBlock={onBlock}
|
||||
onBlockAndReportSpam={onBlockAndReportSpam}
|
||||
onUnblock={() => {
|
||||
acceptConversation={() => {
|
||||
throw new Error(
|
||||
'Should not be able to unblock from MandatoryProfileSharingActions'
|
||||
);
|
||||
}}
|
||||
onDelete={onDelete}
|
||||
blockConversation={blockConversation}
|
||||
conversationId={conversationId}
|
||||
deleteConversation={deleteConversation}
|
||||
i18n={i18n}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
title={title}
|
||||
conversationType={conversationType}
|
||||
state={mrState}
|
||||
|
@ -103,7 +109,7 @@ export function MandatoryProfileSharingActions({
|
|||
{i18n('MessageRequests--delete')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={onAccept}
|
||||
onClick={() => acceptConversation(conversationId)}
|
||||
variant={ButtonVariant.SecondaryAffirmative}
|
||||
>
|
||||
{i18n('MessageRequests--continue')}
|
||||
|
|
|
@ -13,17 +13,17 @@ import enMessages from '../../../_locales/en/messages.json';
|
|||
const i18n = setupI18n('en', enMessages);
|
||||
|
||||
const getBaseProps = (isGroup = false): MessageRequestActionsProps => ({
|
||||
conversationId: '123',
|
||||
i18n,
|
||||
conversationType: isGroup ? 'group' : 'direct',
|
||||
firstName: text('firstName', 'Cayce'),
|
||||
title: isGroup
|
||||
? text('title', 'NYC Rock Climbers')
|
||||
: text('title', 'Cayce Bollard'),
|
||||
onBlock: action('block'),
|
||||
onDelete: action('delete'),
|
||||
onBlockAndReportSpam: action('blockAndReportSpam'),
|
||||
onUnblock: action('unblock'),
|
||||
onAccept: action('accept'),
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockAndReportSpam: action('blockAndReportSpam'),
|
||||
blockConversation: action('blockConversation'),
|
||||
deleteConversation: action('deleteConversation'),
|
||||
});
|
||||
|
||||
export default {
|
||||
|
|
|
@ -15,7 +15,6 @@ import type { LocalizerType } from '../../types/Util';
|
|||
|
||||
export type Props = {
|
||||
i18n: LocalizerType;
|
||||
onAccept(): unknown;
|
||||
} & Omit<ContactNameProps, 'module'> &
|
||||
Omit<
|
||||
MessageRequestActionsConfirmationProps,
|
||||
|
@ -23,15 +22,15 @@ export type Props = {
|
|||
>;
|
||||
|
||||
export function MessageRequestActions({
|
||||
acceptConversation,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
conversationId,
|
||||
conversationType,
|
||||
deleteConversation,
|
||||
firstName,
|
||||
i18n,
|
||||
isBlocked,
|
||||
onAccept,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onDelete,
|
||||
onUnblock,
|
||||
title,
|
||||
}: Props): JSX.Element {
|
||||
const [mrState, setMrState] = React.useState(MessageRequestState.default);
|
||||
|
@ -40,15 +39,16 @@ export function MessageRequestActions({
|
|||
<>
|
||||
{mrState !== MessageRequestState.default ? (
|
||||
<MessageRequestActionsConfirmation
|
||||
i18n={i18n}
|
||||
onBlock={onBlock}
|
||||
onBlockAndReportSpam={onBlockAndReportSpam}
|
||||
onUnblock={onUnblock}
|
||||
onDelete={onDelete}
|
||||
title={title}
|
||||
acceptConversation={acceptConversation}
|
||||
blockAndReportSpam={blockAndReportSpam}
|
||||
blockConversation={blockConversation}
|
||||
conversationId={conversationId}
|
||||
conversationType={conversationType}
|
||||
state={mrState}
|
||||
deleteConversation={deleteConversation}
|
||||
i18n={i18n}
|
||||
onChangeState={setMrState}
|
||||
state={mrState}
|
||||
title={title}
|
||||
/>
|
||||
) : null}
|
||||
<div className="module-message-request-actions">
|
||||
|
@ -102,7 +102,7 @@ export function MessageRequestActions({
|
|||
)}
|
||||
{!isBlocked ? (
|
||||
<Button
|
||||
onClick={onAccept}
|
||||
onClick={() => acceptConversation(conversationId)}
|
||||
variant={ButtonVariant.SecondaryAffirmative}
|
||||
>
|
||||
{i18n('MessageRequests--accept')}
|
||||
|
|
|
@ -16,25 +16,27 @@ export enum MessageRequestState {
|
|||
}
|
||||
|
||||
export type Props = {
|
||||
i18n: LocalizerType;
|
||||
acceptConversation(conversationId: string): unknown;
|
||||
blockAndReportSpam(conversationId: string): unknown;
|
||||
blockConversation(conversationId: string): unknown;
|
||||
conversationId: string;
|
||||
conversationType: 'group' | 'direct';
|
||||
deleteConversation(conversationId: string): unknown;
|
||||
i18n: LocalizerType;
|
||||
isBlocked?: boolean;
|
||||
onBlock(): unknown;
|
||||
onBlockAndReportSpam(): unknown;
|
||||
onUnblock(): unknown;
|
||||
onDelete(): unknown;
|
||||
state: MessageRequestState;
|
||||
onChangeState(state: MessageRequestState): unknown;
|
||||
state: MessageRequestState;
|
||||
} & Omit<ContactNameProps, 'module'>;
|
||||
|
||||
export function MessageRequestActionsConfirmation({
|
||||
acceptConversation,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
conversationId,
|
||||
conversationType,
|
||||
deleteConversation,
|
||||
i18n,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onChangeState,
|
||||
onDelete,
|
||||
onUnblock,
|
||||
state,
|
||||
title,
|
||||
}: Props): JSX.Element | null {
|
||||
|
@ -58,14 +60,14 @@ export function MessageRequestActionsConfirmation({
|
|||
? [
|
||||
{
|
||||
text: i18n('MessageRequests--block-and-report-spam'),
|
||||
action: onBlockAndReportSpam,
|
||||
action: () => blockAndReportSpam(conversationId),
|
||||
style: 'negative' as const,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
text: i18n('MessageRequests--block'),
|
||||
action: onBlock,
|
||||
action: () => blockConversation(conversationId),
|
||||
style: 'negative',
|
||||
},
|
||||
]}
|
||||
|
@ -95,7 +97,7 @@ export function MessageRequestActionsConfirmation({
|
|||
actions={[
|
||||
{
|
||||
text: i18n('MessageRequests--unblock'),
|
||||
action: onUnblock,
|
||||
action: () => acceptConversation(conversationId),
|
||||
style: 'affirmative',
|
||||
},
|
||||
]}
|
||||
|
@ -123,7 +125,7 @@ export function MessageRequestActionsConfirmation({
|
|||
actions={[
|
||||
{
|
||||
text: i18n(`MessageRequests--delete-${conversationType}`),
|
||||
action: onDelete,
|
||||
action: () => deleteConversation(conversationId),
|
||||
style: 'negative',
|
||||
},
|
||||
]}
|
||||
|
|
|
@ -321,10 +321,10 @@ const actions = () => ({
|
|||
'reviewMessageRequestNameCollision'
|
||||
),
|
||||
|
||||
onBlock: action('onBlock'),
|
||||
onBlockAndReportSpam: action('onBlockAndReportSpam'),
|
||||
onDelete: action('onDelete'),
|
||||
onUnblock: action('onUnblock'),
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockAndReportSpam: action('blockAndReportSpam'),
|
||||
blockConversation: action('blockConversation'),
|
||||
deleteConversation: action('deleteConversation'),
|
||||
removeMember: action('removeMember'),
|
||||
|
||||
unblurAvatar: action('unblurAvatar'),
|
||||
|
|
|
@ -165,10 +165,10 @@ export type PropsActionsType = {
|
|||
loadNewerMessages: (messageId: string) => unknown;
|
||||
loadNewestMessages: (messageId: string, setFocus?: boolean) => unknown;
|
||||
markMessageRead: (messageId: string) => unknown;
|
||||
onBlock: (conversationId: string) => unknown;
|
||||
onBlockAndReportSpam: (conversationId: string) => unknown;
|
||||
onDelete: (conversationId: string) => unknown;
|
||||
onUnblock: (conversationId: string) => unknown;
|
||||
blockConversation: (conversationId: string) => unknown;
|
||||
blockAndReportSpam: (conversationId: string) => unknown;
|
||||
deleteConversation: (conversationId: string) => unknown;
|
||||
acceptConversation: (conversationId: string) => unknown;
|
||||
peekGroupCallForTheFirstTime: (conversationId: string) => unknown;
|
||||
peekGroupCallIfItHasMembers: (conversationId: string) => unknown;
|
||||
removeMember: (conversationId: string) => unknown;
|
||||
|
@ -224,10 +224,10 @@ const getActions = createSelector(
|
|||
'loadNewestMessages',
|
||||
'markMessageRead',
|
||||
'markViewed',
|
||||
'onBlock',
|
||||
'onBlockAndReportSpam',
|
||||
'onDelete',
|
||||
'onUnblock',
|
||||
'acceptConversation',
|
||||
'blockAndReportSpam',
|
||||
'blockConversation',
|
||||
'deleteConversation',
|
||||
'peekGroupCallForTheFirstTime',
|
||||
'peekGroupCallIfItHasMembers',
|
||||
'removeMember',
|
||||
|
@ -827,10 +827,14 @@ export class Timeline extends React.Component<
|
|||
|
||||
public override render(): JSX.Element | null {
|
||||
const {
|
||||
acceptConversation,
|
||||
acknowledgeGroupMemberNameCollisions,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
clearInvitedUuidsForNewlyCreatedGroup,
|
||||
closeContactSpoofingReview,
|
||||
contactSpoofingReview,
|
||||
deleteConversation,
|
||||
getPreferredBadge,
|
||||
getTimestampForMessage,
|
||||
haveNewest,
|
||||
|
@ -844,15 +848,11 @@ export class Timeline extends React.Component<
|
|||
items,
|
||||
messageLoadingState,
|
||||
oldestUnseenIndex,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onDelete,
|
||||
onUnblock,
|
||||
removeMember,
|
||||
renderContactSpoofingReviewDialog,
|
||||
renderHeroRow,
|
||||
renderItem,
|
||||
renderTypingBubble,
|
||||
renderContactSpoofingReviewDialog,
|
||||
reviewGroupMemberNameCollision,
|
||||
reviewMessageRequestNameCollision,
|
||||
showContactModal,
|
||||
|
@ -1082,14 +1082,14 @@ export class Timeline extends React.Component<
|
|||
let contactSpoofingReviewDialog: ReactNode;
|
||||
if (contactSpoofingReview) {
|
||||
const commonProps = {
|
||||
acceptConversation,
|
||||
blockAndReportSpam,
|
||||
blockConversation,
|
||||
deleteConversation,
|
||||
getPreferredBadge,
|
||||
i18n,
|
||||
onBlock,
|
||||
onBlockAndReportSpam,
|
||||
onClose: closeContactSpoofingReview,
|
||||
onDelete,
|
||||
onShowContactModal: showContactModal,
|
||||
onUnblock,
|
||||
removeMember,
|
||||
theme,
|
||||
};
|
||||
|
|
|
@ -40,10 +40,12 @@ const createProps = (
|
|||
hasGroupLink = false,
|
||||
expireTimer?: DurationInSeconds
|
||||
): Props => ({
|
||||
acceptConversation: action('acceptConversation'),
|
||||
addMembers: async () => {
|
||||
action('addMembers');
|
||||
},
|
||||
areWeASubscriber: false,
|
||||
blockConversation: action('blockConversation'),
|
||||
canEditGroupInfo: false,
|
||||
canAddNewMembers: false,
|
||||
conversation: expireTimer
|
||||
|
@ -90,9 +92,7 @@ const createProps = (
|
|||
updateGroupAttributes: async () => {
|
||||
action('updateGroupAttributes')();
|
||||
},
|
||||
onBlock: action('onBlock'),
|
||||
onLeave: action('onLeave'),
|
||||
onUnblock: action('onUnblock'),
|
||||
deleteAvatarFromDisk: action('deleteAvatarFromDisk'),
|
||||
replaceAvatar: action('replaceAvatar'),
|
||||
saveAvatarToDisk: action('saveAvatarToDisk'),
|
||||
|
|
|
@ -96,9 +96,7 @@ export type StateProps = {
|
|||
title?: string;
|
||||
}>
|
||||
) => Promise<void>;
|
||||
onBlock: () => void;
|
||||
onLeave: () => void;
|
||||
onUnblock: () => void;
|
||||
theme: ThemeType;
|
||||
userAvatarData: Array<AvatarDataType>;
|
||||
renderChooseGroupMembersModal: (
|
||||
|
@ -110,6 +108,8 @@ export type StateProps = {
|
|||
};
|
||||
|
||||
type ActionProps = {
|
||||
acceptConversation: (id: string) => void;
|
||||
blockConversation: (id: string) => void;
|
||||
deleteAvatarFromDisk: DeleteAvatarFromDiskActionType;
|
||||
loadRecentMediaItems: (id: string, limit: number) => void;
|
||||
onOutgoingAudioCallInConversation: (conversationId: string) => unknown;
|
||||
|
@ -128,9 +128,11 @@ type ActionProps = {
|
|||
export type Props = StateProps & ActionProps;
|
||||
|
||||
export function ConversationDetails({
|
||||
acceptConversation,
|
||||
addMembers,
|
||||
areWeASubscriber,
|
||||
badges,
|
||||
blockConversation,
|
||||
canEditGroupInfo,
|
||||
canAddNewMembers,
|
||||
conversation,
|
||||
|
@ -146,11 +148,9 @@ export function ConversationDetails({
|
|||
memberships,
|
||||
maxGroupSize,
|
||||
maxRecommendedGroupSize,
|
||||
onBlock,
|
||||
onLeave,
|
||||
onOutgoingAudioCallInConversation,
|
||||
onOutgoingVideoCallInConversation,
|
||||
onUnblock,
|
||||
pendingApprovalMemberships,
|
||||
pendingMemberships,
|
||||
renderChooseGroupMembersModal,
|
||||
|
@ -551,15 +551,16 @@ export function ConversationDetails({
|
|||
|
||||
{!conversation.isMe && (
|
||||
<ConversationDetailsActions
|
||||
acceptConversation={acceptConversation}
|
||||
blockConversation={blockConversation}
|
||||
cannotLeaveBecauseYouAreLastAdmin={cannotLeaveBecauseYouAreLastAdmin}
|
||||
conversationId={conversation.id}
|
||||
conversationTitle={conversation.title}
|
||||
i18n={i18n}
|
||||
isBlocked={Boolean(conversation.isBlocked)}
|
||||
isGroup={isGroup}
|
||||
left={Boolean(conversation.left)}
|
||||
onBlock={onBlock}
|
||||
onLeave={onLeave}
|
||||
onUnblock={onUnblock}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
|
|
@ -19,19 +19,20 @@ export default {
|
|||
};
|
||||
|
||||
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
|
||||
acceptConversation: action('acceptConversation'),
|
||||
blockConversation: action('blockConversation'),
|
||||
cannotLeaveBecauseYouAreLastAdmin: isBoolean(
|
||||
overrideProps.cannotLeaveBecauseYouAreLastAdmin
|
||||
)
|
||||
? overrideProps.cannotLeaveBecauseYouAreLastAdmin
|
||||
: false,
|
||||
conversationId: '123',
|
||||
conversationTitle: overrideProps.conversationTitle || '',
|
||||
left: isBoolean(overrideProps.left) ? overrideProps.left : false,
|
||||
onBlock: action('onBlock'),
|
||||
onLeave: action('onLeave'),
|
||||
onUnblock: action('onUnblock'),
|
||||
i18n,
|
||||
isBlocked: isBoolean(overrideProps.isBlocked),
|
||||
isGroup: true,
|
||||
left: isBoolean(overrideProps.left) ? overrideProps.left : false,
|
||||
onLeave: action('onLeave'),
|
||||
});
|
||||
|
||||
export function Basic(): JSX.Element {
|
||||
|
|
|
@ -14,27 +14,29 @@ import { PanelSection } from './PanelSection';
|
|||
import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon';
|
||||
|
||||
export type Props = {
|
||||
acceptConversation: (id: string) => void;
|
||||
blockConversation: (id: string) => void;
|
||||
cannotLeaveBecauseYouAreLastAdmin: boolean;
|
||||
conversationId: string;
|
||||
conversationTitle: string;
|
||||
i18n: LocalizerType;
|
||||
isBlocked: boolean;
|
||||
isGroup: boolean;
|
||||
left: boolean;
|
||||
onBlock: () => void;
|
||||
onLeave: () => void;
|
||||
onUnblock: () => void;
|
||||
};
|
||||
|
||||
export function ConversationDetailsActions({
|
||||
acceptConversation,
|
||||
blockConversation,
|
||||
cannotLeaveBecauseYouAreLastAdmin,
|
||||
conversationId,
|
||||
conversationTitle,
|
||||
i18n,
|
||||
isBlocked,
|
||||
isGroup,
|
||||
left,
|
||||
onBlock,
|
||||
onLeave,
|
||||
onUnblock,
|
||||
}: Props): JSX.Element {
|
||||
const [confirmLeave, gLeave] = useState<boolean>(false);
|
||||
const [confirmGroupBlock, gGroupBlock] = useState<boolean>(false);
|
||||
|
@ -193,7 +195,7 @@ export function ConversationDetailsActions({
|
|||
text: i18n(
|
||||
'ConversationDetailsActions--block-group-modal-confirm'
|
||||
),
|
||||
action: onBlock,
|
||||
action: () => blockConversation(conversationId),
|
||||
style: 'affirmative',
|
||||
},
|
||||
]}
|
||||
|
@ -214,7 +216,7 @@ export function ConversationDetailsActions({
|
|||
text: i18n(
|
||||
'ConversationDetailsActions--unblock-group-modal-confirm'
|
||||
),
|
||||
action: onUnblock,
|
||||
action: () => acceptConversation(conversationId),
|
||||
style: 'affirmative',
|
||||
},
|
||||
]}
|
||||
|
@ -234,7 +236,7 @@ export function ConversationDetailsActions({
|
|||
actions={[
|
||||
{
|
||||
text: i18n('MessageRequests--block'),
|
||||
action: onBlock,
|
||||
action: () => blockConversation(conversationId),
|
||||
style: 'affirmative',
|
||||
},
|
||||
]}
|
||||
|
@ -253,7 +255,7 @@ export function ConversationDetailsActions({
|
|||
actions={[
|
||||
{
|
||||
text: i18n('MessageRequests--unblock'),
|
||||
action: onUnblock,
|
||||
action: () => acceptConversation(conversationId),
|
||||
style: 'affirmative',
|
||||
},
|
||||
]}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue