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';
|
2022-03-02 18:24:28 +00:00
|
|
|
import type { SafetyNumberProps } from '../../components/SafetyNumberChangeDialog';
|
2024-03-15 14:38:26 +00:00
|
|
|
import { getContactSafetyNumberSelector } from '../selectors/safetyNumber';
|
2020-06-26 00:08:58 +00:00
|
|
|
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);
|
2024-03-15 14:38:26 +00:00
|
|
|
const contactSafetyNumberSelector = useSelector(
|
|
|
|
getContactSafetyNumberSelector
|
|
|
|
);
|
|
|
|
const safetyNumberContact = contactSafetyNumberSelector(contactID);
|
2024-03-13 20:44:13 +00:00
|
|
|
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}
|
2024-03-14 19:35:03 +00:00
|
|
|
safetyNumber={safetyNumberContact?.safetyNumber ?? null}
|
2024-03-13 20:44:13 +00:00
|
|
|
toggleVerified={toggleVerified}
|
2024-03-14 19:35:03 +00:00
|
|
|
verificationDisabled={safetyNumberContact?.verificationDisabled ?? null}
|
2024-03-13 20:44:13 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|