2021-01-29 21:19:24 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { PropsType } from '../../components/conversation/conversation-details/GroupLinkManagement';
|
|
|
|
import { GroupLinkManagement } from '../../components/conversation/conversation-details/GroupLinkManagement';
|
2021-01-29 21:19:24 +00:00
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
|
|
|
|
export type SmartGroupLinkManagementProps = {
|
|
|
|
changeHasGroupLink: (value: boolean) => void;
|
|
|
|
conversationId: string;
|
|
|
|
copyGroupLink: (groupLink: string) => void;
|
|
|
|
generateNewGroupLink: () => void;
|
|
|
|
setAccessControlAddFromInviteLinkSetting: (value: boolean) => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (
|
|
|
|
state: StateType,
|
|
|
|
props: SmartGroupLinkManagementProps
|
|
|
|
): PropsType => {
|
|
|
|
const conversation = getConversationSelector(state)(props.conversationId);
|
2021-03-02 16:27:11 +00:00
|
|
|
const isAdmin = Boolean(conversation?.areWeAdmin);
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
...props,
|
|
|
|
conversation,
|
|
|
|
i18n: getIntl(state),
|
2021-03-02 16:27:11 +00:00
|
|
|
isAdmin,
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps);
|
|
|
|
|
|
|
|
export const SmartGroupLinkManagement = smart(GroupLinkManagement);
|