2021-04-29 18:32:38 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// 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-26 19:15:33 +00:00
|
|
|
import { PendingInvites } from '../../components/conversation/conversation-details/PendingInvites';
|
2021-11-18 22:27:48 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2021-10-26 22:59:08 +00:00
|
|
|
import {
|
|
|
|
getConversationByIdSelector,
|
2023-08-16 20:54:39 +00:00
|
|
|
getConversationByServiceIdSelector,
|
2021-10-26 22:59:08 +00:00
|
|
|
} from '../selectors/conversations';
|
2021-05-13 14:47:30 +00:00
|
|
|
import { getGroupMemberships } from '../../util/getGroupMemberships';
|
2022-09-15 19:17:15 +00:00
|
|
|
import { assertDev } from '../../util/assert';
|
2023-08-10 16:43:33 +00:00
|
|
|
import type { AciString } from '../../types/ServiceId';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
export type SmartPendingInvitesProps = {
|
|
|
|
conversationId: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci: AciString;
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartPendingInvites = memo(function SmartPendingInvites({
|
|
|
|
conversationId,
|
|
|
|
ourAci,
|
|
|
|
}: SmartPendingInvitesProps) {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const theme = useSelector(getTheme);
|
|
|
|
const getPreferredBadge = useSelector(getPreferredBadgeSelector);
|
|
|
|
const conversationSelector = useSelector(getConversationByIdSelector);
|
|
|
|
const conversationByServiceIdSelector = useSelector(
|
|
|
|
getConversationByServiceIdSelector
|
|
|
|
);
|
|
|
|
const conversation = conversationSelector(conversationId);
|
2022-09-15 19:17:15 +00:00
|
|
|
assertDev(
|
2021-04-29 18:32:38 +00:00
|
|
|
conversation,
|
|
|
|
'<SmartPendingInvites> expected a conversation to be found'
|
|
|
|
);
|
2024-03-13 20:44:13 +00:00
|
|
|
const groupMemberships = getGroupMemberships(
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation,
|
2024-03-13 20:44:13 +00:00
|
|
|
conversationByServiceIdSelector
|
|
|
|
);
|
|
|
|
const {
|
|
|
|
approvePendingMembershipFromGroupV2,
|
|
|
|
revokePendingMembershipsFromGroupV2,
|
|
|
|
} = useConversationsActions();
|
|
|
|
return (
|
|
|
|
<PendingInvites
|
|
|
|
i18n={i18n}
|
|
|
|
theme={theme}
|
|
|
|
getPreferredBadge={getPreferredBadge}
|
|
|
|
conversation={conversation}
|
|
|
|
ourAci={ourAci}
|
|
|
|
pendingMemberships={groupMemberships.pendingMemberships}
|
|
|
|
pendingApprovalMemberships={groupMemberships.pendingApprovalMemberships}
|
|
|
|
approvePendingMembershipFromGroupV2={approvePendingMembershipFromGroupV2}
|
|
|
|
revokePendingMembershipsFromGroupV2={revokePendingMembershipsFromGroupV2}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|