2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-05-27 21:37:06 +00:00
|
|
|
import * as React from 'react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType as ContactNameProps } from './ContactName';
|
|
|
|
import { ContactName } from './ContactName';
|
2021-04-27 19:29:59 +00:00
|
|
|
import { ConfirmationDialog } from '../ConfirmationDialog';
|
2020-05-27 21:37:06 +00:00
|
|
|
import { Intl } from '../Intl';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2020-05-27 21:37:06 +00:00
|
|
|
|
|
|
|
export enum MessageRequestState {
|
|
|
|
blocking,
|
|
|
|
deleting,
|
|
|
|
unblocking,
|
|
|
|
default,
|
|
|
|
}
|
|
|
|
|
|
|
|
export type Props = {
|
2022-12-06 19:03:09 +00:00
|
|
|
acceptConversation(conversationId: string): unknown;
|
|
|
|
blockAndReportSpam(conversationId: string): unknown;
|
|
|
|
blockConversation(conversationId: string): unknown;
|
|
|
|
conversationId: string;
|
2020-05-27 21:37:06 +00:00
|
|
|
conversationType: 'group' | 'direct';
|
2022-12-06 19:03:09 +00:00
|
|
|
deleteConversation(conversationId: string): unknown;
|
|
|
|
i18n: LocalizerType;
|
2020-05-27 21:37:06 +00:00
|
|
|
isBlocked?: boolean;
|
|
|
|
onChangeState(state: MessageRequestState): unknown;
|
2022-12-06 19:03:09 +00:00
|
|
|
state: MessageRequestState;
|
2021-09-16 16:15:43 +00:00
|
|
|
} & Omit<ContactNameProps, 'module'>;
|
2020-05-27 21:37:06 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function MessageRequestActionsConfirmation({
|
2022-12-06 19:03:09 +00:00
|
|
|
acceptConversation,
|
|
|
|
blockAndReportSpam,
|
|
|
|
blockConversation,
|
|
|
|
conversationId,
|
2020-07-29 23:20:05 +00:00
|
|
|
conversationType,
|
2022-12-06 19:03:09 +00:00
|
|
|
deleteConversation,
|
2020-05-27 21:37:06 +00:00
|
|
|
i18n,
|
2020-07-29 23:20:05 +00:00
|
|
|
onChangeState,
|
2020-05-27 21:37:06 +00:00
|
|
|
state,
|
2020-07-29 23:20:05 +00:00
|
|
|
title,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: Props): JSX.Element | null {
|
2020-05-27 21:37:06 +00:00
|
|
|
if (state === MessageRequestState.blocking) {
|
|
|
|
return (
|
2021-04-27 19:29:59 +00:00
|
|
|
<ConfirmationDialog
|
2022-09-27 20:24:21 +00:00
|
|
|
dialogName="messageRequestActionsConfirmation.blocking"
|
2020-05-27 21:37:06 +00:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
2023-03-28 18:26:46 +00:00
|
|
|
conversationType === 'direct' ? (
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id="MessageRequests--block-direct-confirm-title"
|
|
|
|
components={{
|
|
|
|
title: <ContactName key="name" title={title} />,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id="MessageRequests--block-group-confirm-title"
|
|
|
|
components={{
|
|
|
|
title: <ContactName key="name" title={title} />,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2020-05-27 21:37:06 +00:00
|
|
|
}
|
|
|
|
actions={[
|
2021-05-27 20:17:05 +00:00
|
|
|
...(conversationType === 'direct'
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--block-and-report-spam'),
|
2022-12-06 19:03:09 +00:00
|
|
|
action: () => blockAndReportSpam(conversationId),
|
2021-05-27 20:17:05 +00:00
|
|
|
style: 'negative' as const,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []),
|
2020-05-27 21:37:06 +00:00
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--block'),
|
2022-12-06 19:03:09 +00:00
|
|
|
action: () => blockConversation(conversationId),
|
2020-05-27 21:37:06 +00:00
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
2023-03-28 18:26:46 +00:00
|
|
|
{conversationType === 'direct'
|
|
|
|
? i18n('MessageRequests--block-direct-confirm-body')
|
|
|
|
: i18n('MessageRequests--block-group-confirm-body')}
|
2021-04-27 19:29:59 +00:00
|
|
|
</ConfirmationDialog>
|
2020-05-27 21:37:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === MessageRequestState.unblocking) {
|
|
|
|
return (
|
2021-04-27 19:29:59 +00:00
|
|
|
<ConfirmationDialog
|
2022-09-27 20:24:21 +00:00
|
|
|
dialogName="messageRequestActionsConfirmation.unblocking"
|
2020-05-27 21:37:06 +00:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
2022-11-09 03:40:23 +00:00
|
|
|
id="MessageRequests--unblock-direct-confirm-title"
|
|
|
|
components={{
|
|
|
|
name: <ContactName key="name" title={title} />,
|
|
|
|
}}
|
2020-05-27 21:37:06 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
text: i18n('MessageRequests--unblock'),
|
2022-12-06 19:03:09 +00:00
|
|
|
action: () => acceptConversation(conversationId),
|
2020-05-27 21:37:06 +00:00
|
|
|
style: 'affirmative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
2023-03-28 18:26:46 +00:00
|
|
|
{conversationType === 'direct'
|
|
|
|
? i18n('MessageRequests--unblock-direct-confirm-body')
|
|
|
|
: i18n('MessageRequests--unblock-group-confirm-body')}
|
2021-04-27 19:29:59 +00:00
|
|
|
</ConfirmationDialog>
|
2020-05-27 21:37:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === MessageRequestState.deleting) {
|
|
|
|
return (
|
2021-04-27 19:29:59 +00:00
|
|
|
<ConfirmationDialog
|
2022-09-27 20:24:21 +00:00
|
|
|
dialogName="messageRequestActionsConfirmation.deleting"
|
2020-05-27 21:37:06 +00:00
|
|
|
i18n={i18n}
|
|
|
|
onClose={() => {
|
|
|
|
onChangeState(MessageRequestState.default);
|
|
|
|
}}
|
|
|
|
title={
|
2023-03-29 17:15:54 +00:00
|
|
|
conversationType === 'direct' ? (
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id="MessageRequests--delete-direct-confirm-title"
|
|
|
|
components={{
|
|
|
|
title: <ContactName key="name" title={title} />,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id="MessageRequests--delete-group-confirm-title"
|
|
|
|
components={{
|
|
|
|
title: <ContactName key="name" title={title} />,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2020-05-27 21:37:06 +00:00
|
|
|
}
|
|
|
|
actions={[
|
|
|
|
{
|
2023-03-28 18:26:46 +00:00
|
|
|
text:
|
|
|
|
conversationType === 'direct'
|
|
|
|
? i18n('MessageRequests--delete-direct')
|
|
|
|
: i18n('MessageRequests--delete-group'),
|
2022-12-06 19:03:09 +00:00
|
|
|
action: () => deleteConversation(conversationId),
|
2020-05-27 21:37:06 +00:00
|
|
|
style: 'negative',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
2023-03-28 18:26:46 +00:00
|
|
|
{conversationType === 'direct'
|
|
|
|
? i18n('MessageRequests--delete-direct-confirm-body')
|
|
|
|
: i18n('MessageRequests--delete-group-confirm-body')}
|
2021-04-27 19:29:59 +00:00
|
|
|
</ConfirmationDialog>
|
2020-05-27 21:37:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|