2020-10-30 20:34:04 +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';
|
2020-06-26 00:08:58 +00:00
|
|
|
import { SafetyNumberViewer } from '../../components/SafetyNumberViewer';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2022-03-02 18:24:28 +00:00
|
|
|
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog';
|
2020-06-26 00:08:58 +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';
|
2020-06-26 00:08:58 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartSafetyNumberViewer = memo(function SmartSafetyNumberViewer({
|
|
|
|
contactID,
|
|
|
|
onClose,
|
|
|
|
}: SafetyNumberProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const safetyNumberContact = useSelector((state: StateType) => {
|
|
|
|
return getContactSafetyNumber(state, { contactID });
|
|
|
|
});
|
|
|
|
const conversationSelector = useSelector(getConversationSelector);
|
|
|
|
const contact = conversationSelector(contactID);
|
2020-06-26 00:08:58 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
const { generateSafetyNumber, toggleVerified } = useSafetyNumberActions();
|
2020-06-26 00:08:58 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
return (
|
|
|
|
<SafetyNumberViewer
|
|
|
|
contact={contact}
|
|
|
|
generateSafetyNumber={generateSafetyNumber}
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={onClose}
|
|
|
|
safetyNumber={safetyNumberContact.safetyNumber}
|
|
|
|
toggleVerified={toggleVerified}
|
|
|
|
verificationDisabled={safetyNumberContact.verificationDisabled}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|