Implemented ability to quickly add a user to a group
This commit is contained in:
parent
190cd9408b
commit
22bf3ebcc0
30 changed files with 855 additions and 70 deletions
37
ts/state/smart/AddUserToAnotherGroupModal.tsx
Normal file
37
ts/state/smart/AddUserToAnotherGroupModal.tsx
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
import { AddUserToAnotherGroupModal } from '../../components/AddUserToAnotherGroupModal';
|
||||
import type { StateType } from '../reducer';
|
||||
import {
|
||||
getAllGroupsWithInviteAccess,
|
||||
getContactSelector,
|
||||
} from '../selectors/conversations';
|
||||
import { getIntl, getRegionCode, getTheme } from '../selectors/user';
|
||||
|
||||
export type Props = {
|
||||
contactID: string;
|
||||
};
|
||||
|
||||
const mapStateToProps = (state: StateType, props: Props) => {
|
||||
const candidateConversations = getAllGroupsWithInviteAccess(state);
|
||||
const getContact = getContactSelector(state);
|
||||
|
||||
const regionCode = getRegionCode(state);
|
||||
|
||||
return {
|
||||
contact: getContact(props.contactID),
|
||||
i18n: getIntl(state),
|
||||
theme: getTheme(state),
|
||||
candidateConversations,
|
||||
regionCode,
|
||||
};
|
||||
};
|
||||
|
||||
const smart = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
export const SmartAddUserToAnotherGroupModal = smart(
|
||||
AddUserToAnotherGroupModal
|
||||
);
|
|
@ -91,7 +91,7 @@ const mapStateToProps = (state: StateType) => {
|
|||
titleBarDoubleClick: (): void => {
|
||||
window.titleBarDoubleClick();
|
||||
},
|
||||
toastType: state.toast.toastType,
|
||||
toast: state.toast.toast,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { sortBy } from 'lodash';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
|
@ -11,6 +12,7 @@ import { ConversationDetails } from '../../components/conversation/conversation-
|
|||
import {
|
||||
getConversationByIdSelector,
|
||||
getConversationByUuidSelector,
|
||||
getAllComposableConversations,
|
||||
} from '../selectors/conversations';
|
||||
import { getGroupMemberships } from '../../util/getGroupMemberships';
|
||||
import { getActiveCallState } from '../selectors/calling';
|
||||
|
@ -84,6 +86,7 @@ const mapStateToProps = (
|
|||
);
|
||||
|
||||
const canEditGroupInfo = Boolean(conversation.canEditGroupInfo);
|
||||
const canAddNewMembers = Boolean(conversation.canAddNewMembers);
|
||||
const isAdmin = Boolean(conversation.areWeAdmin);
|
||||
|
||||
const hasGroupLink =
|
||||
|
@ -98,11 +101,25 @@ const mapStateToProps = (
|
|||
|
||||
const badges = getBadgesSelector(state)(conversation.badges);
|
||||
|
||||
const groupsInCommon =
|
||||
conversation.type === 'direct'
|
||||
? getAllComposableConversations(state).filter(
|
||||
c =>
|
||||
c.type === 'group' &&
|
||||
(c.memberships ?? []).some(
|
||||
member => member.uuid === conversation.uuid
|
||||
)
|
||||
)
|
||||
: [];
|
||||
|
||||
const groupsInCommonSorted = sortBy(groupsInCommon, 'title');
|
||||
|
||||
return {
|
||||
...props,
|
||||
areWeASubscriber: getAreWeASubscriber(state),
|
||||
badges,
|
||||
canEditGroupInfo,
|
||||
canAddNewMembers,
|
||||
conversation: {
|
||||
...conversation,
|
||||
...getConversationColorAttributes(conversation),
|
||||
|
@ -114,6 +131,7 @@ const mapStateToProps = (
|
|||
...groupMemberships,
|
||||
userAvatarData: conversation.avatars || [],
|
||||
hasGroupLink,
|
||||
groupsInCommon: groupsInCommonSorted,
|
||||
isGroup: conversation.type === 'group',
|
||||
theme: getTheme(state),
|
||||
renderChooseGroupMembersModal,
|
||||
|
|
|
@ -14,7 +14,8 @@ import { SmartStoriesSettingsModal } from './StoriesSettingsModal';
|
|||
import { getConversationsStoppingSend } from '../selectors/conversations';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { getIntl, getTheme } from '../selectors/user';
|
||||
import { SmartAddUserToAnotherGroupModal } from './AddUserToAnotherGroupModal';
|
||||
|
||||
function renderProfileEditor(): JSX.Element {
|
||||
return <SmartProfileEditorModal />;
|
||||
|
@ -43,6 +44,7 @@ const mapStateToProps = (state: StateType) => {
|
|||
...state.globalModals,
|
||||
hasSafetyNumberChangeModal: getConversationsStoppingSend(state).length > 0,
|
||||
i18n,
|
||||
theme: getTheme(state),
|
||||
renderContactModal,
|
||||
renderForwardMessageModal,
|
||||
renderProfileEditor,
|
||||
|
@ -52,6 +54,15 @@ const mapStateToProps = (state: StateType) => {
|
|||
contactID={String(state.globalModals.safetyNumberModalContactId)}
|
||||
/>
|
||||
),
|
||||
renderAddUserToAnotherGroup: () => {
|
||||
return (
|
||||
<SmartAddUserToAnotherGroupModal
|
||||
contactID={String(
|
||||
state.globalModals.addUserToAnotherGroupModalContactId
|
||||
)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
renderSendAnywayDialog,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue