// Copyright 2023 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import classNames from 'classnames'; import React, { useState } from 'react'; import type { ShowToastAction } from '../../state/ducks/toast'; import { ToastType } from '../../types/Toast'; import type { LocalizerType } from '../../types/Util'; import { ConfirmationDialog } from '../ConfirmationDialog'; // Keep this in sync with iOS and Android const MAX_FORWARD_COUNT = 30; type SelectModeActionsProps = Readonly<{ selectedMessageIds: ReadonlyArray; onExitSelectMode: () => void; onDeleteMessages: () => void; onForwardMessages: () => void; showToast: ShowToastAction; i18n: LocalizerType; }>; export default function SelectModeActions({ selectedMessageIds, onExitSelectMode, onDeleteMessages, onForwardMessages, showToast, i18n, }: SelectModeActionsProps): JSX.Element { const [confirmDelete, setConfirmDelete] = useState(false); const hasSelectedMessages = selectedMessageIds.length >= 1; const tooManyMessagesToForward = selectedMessageIds.length > MAX_FORWARD_COUNT; const canForward = hasSelectedMessages && !tooManyMessagesToForward; const canDelete = hasSelectedMessages; return ( <>
{i18n('icu:SelectModeActions--selectedMessages', { count: selectedMessageIds.length, })}
{confirmDelete && ( { onDeleteMessages(); }, style: 'negative', text: i18n('icu:SelectModeActions__confirmDelete--confirm'), }, ]} dialogName="TimelineMessage/deleteMessage" title={i18n('icu:SelectModeActions__confirmDelete--title', { count: selectedMessageIds.length, })} i18n={i18n} onClose={() => { setConfirmDelete(false); }} > {i18n('icu:SelectModeActions__confirmDelete--description')} )} ); }