signal-desktop/ts/state/smart/PendingInvites.tsx

51 lines
1.6 KiB
TypeScript
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import type { PropsDataType } from '../../components/conversation/conversation-details/PendingInvites';
import { PendingInvites } from '../../components/conversation/conversation-details/PendingInvites';
import type { StateType } from '../reducer';
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,
getConversationByUuidSelector,
} from '../selectors/conversations';
import { getGroupMemberships } from '../../util/getGroupMemberships';
import { assertDev } from '../../util/assert';
2021-11-10 23:01:06 +00:00
import type { UUIDStringType } from '../../types/UUID';
export type SmartPendingInvitesProps = {
conversationId: string;
2021-11-10 23:01:06 +00:00
ourUuid: UUIDStringType;
};
const mapStateToProps = (
state: StateType,
props: SmartPendingInvitesProps
): PropsDataType => {
const conversationSelector = getConversationByIdSelector(state);
2021-10-26 22:59:08 +00:00
const conversationByUuidSelector = getConversationByUuidSelector(state);
const conversation = conversationSelector(props.conversationId);
assertDev(
conversation,
'<SmartPendingInvites> expected a conversation to be found'
);
return {
...props,
2021-10-26 22:59:08 +00:00
...getGroupMemberships(conversation, conversationByUuidSelector),
conversation,
2021-11-18 22:27:48 +00:00
getPreferredBadge: getPreferredBadgeSelector(state),
i18n: getIntl(state),
2021-11-18 22:27:48 +00:00
theme: getTheme(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartPendingInvites = smart(PendingInvites);