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
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
2022-12-05 22:56:23 +00:00
|
|
|
import type { PropsDataType } from '../../components/conversation/conversation-details/PendingInvites';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { PendingInvites } from '../../components/conversation/conversation-details/PendingInvites';
|
|
|
|
import type { StateType } from '../reducer';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
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';
|
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
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: SmartPendingInvitesProps
|
2022-12-05 22:56:23 +00:00
|
|
|
): PropsDataType => {
|
2021-04-29 18:32:38 +00:00
|
|
|
const conversationSelector = getConversationByIdSelector(state);
|
2023-08-16 20:54:39 +00:00
|
|
|
const conversationByServiceIdSelector =
|
|
|
|
getConversationByServiceIdSelector(state);
|
2021-01-29 21:19:24 +00:00
|
|
|
|
2021-04-29 18:32:38 +00:00
|
|
|
const conversation = conversationSelector(props.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'
|
|
|
|
);
|
|
|
|
|
2021-01-29 21:19:24 +00:00
|
|
|
return {
|
|
|
|
...props,
|
2023-08-16 20:54:39 +00:00
|
|
|
...getGroupMemberships(conversation, conversationByServiceIdSelector),
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation,
|
2021-11-18 22:27:48 +00:00
|
|
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
2021-01-29 21:19:24 +00:00
|
|
|
i18n: getIntl(state),
|
2021-11-18 22:27:48 +00:00
|
|
|
theme: getTheme(state),
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartPendingInvites = smart(PendingInvites);
|