2024-02-16 22:16:13 +00:00
|
|
|
// Copyright 2024 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-26 19:48:33 +00:00
|
|
|
import React, { memo, useCallback } from 'react';
|
2024-02-16 22:16:13 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { AboutContactModal } from '../../components/conversation/AboutContactModal';
|
|
|
|
import { isSignalConnection } from '../../util/getSignalConnections';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { getGlobalModalsState } from '../selectors/globalModals';
|
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
2024-03-26 19:48:33 +00:00
|
|
|
import { strictAssert } from '../../util/assert';
|
2024-02-16 22:16:13 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartAboutContactModal = memo(function SmartAboutContactModal() {
|
2024-02-16 22:16:13 +00:00
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const globalModals = useSelector(getGlobalModalsState);
|
|
|
|
const { aboutContactModalContactId: contactId } = globalModals;
|
|
|
|
const getConversation = useSelector(getConversationSelector);
|
|
|
|
|
|
|
|
const { updateSharedGroups, unblurAvatar } = useConversationsActions();
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
const conversation = getConversation(contactId);
|
|
|
|
const { id: conversationId } = conversation ?? {};
|
|
|
|
|
2024-02-16 22:16:13 +00:00
|
|
|
const {
|
|
|
|
toggleAboutContactModal,
|
|
|
|
toggleSignalConnectionsModal,
|
|
|
|
toggleSafetyNumberModal,
|
2024-03-26 19:48:33 +00:00
|
|
|
toggleNotePreviewModal,
|
2024-02-16 22:16:13 +00:00
|
|
|
} = useGlobalModalActions();
|
|
|
|
|
2024-03-26 19:48:33 +00:00
|
|
|
const handleOpenNotePreviewModal = useCallback(() => {
|
|
|
|
strictAssert(conversationId != null, 'conversationId is required');
|
|
|
|
toggleNotePreviewModal({ conversationId });
|
|
|
|
}, [toggleNotePreviewModal, conversationId]);
|
|
|
|
|
|
|
|
if (conversation == null) {
|
2024-02-16 22:16:13 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AboutContactModal
|
|
|
|
i18n={i18n}
|
|
|
|
conversation={conversation}
|
|
|
|
updateSharedGroups={updateSharedGroups}
|
|
|
|
unblurAvatar={unblurAvatar}
|
|
|
|
toggleSignalConnectionsModal={toggleSignalConnectionsModal}
|
|
|
|
toggleSafetyNumberModal={toggleSafetyNumberModal}
|
|
|
|
isSignalConnection={isSignalConnection(conversation)}
|
|
|
|
onClose={toggleAboutContactModal}
|
2024-03-26 19:48:33 +00:00
|
|
|
onOpenNotePreviewModal={handleOpenNotePreviewModal}
|
2024-02-16 22:16:13 +00:00
|
|
|
/>
|
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
});
|