2021-10-06 20:27:14 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2021-10-06 20:27:14 +00:00
|
|
|
import { SafetyNumberModal } from '../../components/SafetyNumberModal';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-10-06 20:27:14 +00:00
|
|
|
import { getContactSafetyNumber } from '../selectors/safetyNumber';
|
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
import { getIntl } from '../selectors/user';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useSafetyNumberActions } from '../ducks/safetyNumber';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
2021-10-06 20:27:14 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export type SmartSafetyNumberModalProps = {
|
2021-10-06 20:27:14 +00:00
|
|
|
contactID: string;
|
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartSafetyNumberModal = memo(function SmartSafetyNumberModal({
|
|
|
|
contactID,
|
|
|
|
}: SmartSafetyNumberModalProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const conversationSelector = useSelector(getConversationSelector);
|
|
|
|
const contact = conversationSelector(contactID);
|
|
|
|
const contactSafetyNumber = useSelector((state: StateType) => {
|
|
|
|
return getContactSafetyNumber(state, { contactID });
|
|
|
|
});
|
|
|
|
const { generateSafetyNumber, toggleVerified } = useSafetyNumberActions();
|
|
|
|
const { toggleSafetyNumberModal } = useGlobalModalActions();
|
|
|
|
return (
|
|
|
|
<SafetyNumberModal
|
|
|
|
i18n={i18n}
|
|
|
|
contact={contact}
|
|
|
|
safetyNumber={contactSafetyNumber.safetyNumber}
|
|
|
|
verificationDisabled={contactSafetyNumber.verificationDisabled}
|
|
|
|
toggleSafetyNumberModal={toggleSafetyNumberModal}
|
|
|
|
generateSafetyNumber={generateSafetyNumber}
|
|
|
|
toggleVerified={toggleVerified}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|