2022-04-05 00:38:22 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-19 17:12:32 +00:00
|
|
|
import React, { memo, useMemo } from 'react';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2022-04-05 00:38:22 +00:00
|
|
|
import { strictAssert } from '../../util/assert';
|
|
|
|
import { ConfirmAdditionsModal } from '../../components/conversation/conversation-details/AddGroupMembersModal/ConfirmAdditionsModal';
|
|
|
|
import type { RequestState } from '../../components/conversation/conversation-details/util';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { getConversationByIdSelector } from '../selectors/conversations';
|
|
|
|
|
|
|
|
export type SmartConfirmAdditionsModalPropsType = {
|
|
|
|
selectedConversationIds: ReadonlyArray<string>;
|
|
|
|
groupTitle: string;
|
|
|
|
makeRequest: () => void;
|
|
|
|
onClose: () => void;
|
|
|
|
requestState: RequestState;
|
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartConfirmAdditionsModal = memo(
|
|
|
|
function SmartConfirmAdditionsModal({
|
|
|
|
selectedConversationIds,
|
|
|
|
groupTitle,
|
|
|
|
makeRequest,
|
|
|
|
onClose,
|
|
|
|
requestState,
|
|
|
|
}: SmartConfirmAdditionsModalPropsType) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const conversationSelector = useSelector(getConversationByIdSelector);
|
|
|
|
|
2024-03-19 17:12:32 +00:00
|
|
|
const selectedContacts = useMemo(() => {
|
|
|
|
return selectedConversationIds.map(conversationId => {
|
|
|
|
const convo = conversationSelector(conversationId);
|
|
|
|
strictAssert(
|
|
|
|
convo,
|
|
|
|
'<SmartChooseGroupMemberModal> selected conversation not found'
|
|
|
|
);
|
|
|
|
return convo;
|
|
|
|
});
|
|
|
|
}, [conversationSelector, selectedConversationIds]);
|
2024-03-13 20:44:13 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ConfirmAdditionsModal
|
|
|
|
i18n={i18n}
|
|
|
|
selectedContacts={selectedContacts}
|
|
|
|
groupTitle={groupTitle}
|
|
|
|
makeRequest={makeRequest}
|
|
|
|
onClose={onClose}
|
|
|
|
requestState={requestState}
|
|
|
|
/>
|
2022-04-05 00:38:22 +00:00
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
}
|
|
|
|
);
|