Allow adding to a group by phone number
This commit is contained in:
parent
76a1a805ef
commit
9568d5792e
49 changed files with 1842 additions and 693 deletions
63
ts/state/smart/ChooseGroupMembersModal.tsx
Normal file
63
ts/state/smart/ChooseGroupMembersModal.tsx
Normal file
|
@ -0,0 +1,63 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { lookupConversationWithoutUuid } from '../../util/lookupConversationWithoutUuid';
|
||||
|
||||
import type { StatePropsType } from '../../components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal';
|
||||
import { ChooseGroupMembersModal } from '../../components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal';
|
||||
|
||||
import { getIntl, getTheme, getRegionCode } from '../selectors/user';
|
||||
import {
|
||||
getCandidateContactsForNewGroup,
|
||||
getConversationByIdSelector,
|
||||
} from '../selectors/conversations';
|
||||
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||
|
||||
export type SmartChooseGroupMembersModalPropsType = {
|
||||
conversationIdsAlreadyInGroup: Set<string>;
|
||||
maxGroupSize: number;
|
||||
confirmAdds: () => void;
|
||||
onClose: () => void;
|
||||
removeSelectedContact: (_: string) => void;
|
||||
searchTerm: string;
|
||||
selectedConversationIds: ReadonlyArray<string>;
|
||||
setSearchTerm: (_: string) => void;
|
||||
toggleSelectedContact: (conversationId: string) => void;
|
||||
};
|
||||
|
||||
const mapStateToProps = (
|
||||
state: StateType,
|
||||
props: SmartChooseGroupMembersModalPropsType
|
||||
): StatePropsType => {
|
||||
const conversationSelector = getConversationByIdSelector(state);
|
||||
|
||||
const candidateContacts = getCandidateContactsForNewGroup(state);
|
||||
const selectedContacts = props.selectedConversationIds.map(conversationId => {
|
||||
const convo = conversationSelector(conversationId);
|
||||
strictAssert(
|
||||
convo,
|
||||
'<SmartChooseGroupMemberModal> selected conversation not found'
|
||||
);
|
||||
return convo;
|
||||
});
|
||||
|
||||
return {
|
||||
...props,
|
||||
regionCode: getRegionCode(state),
|
||||
candidateContacts,
|
||||
getPreferredBadge: getPreferredBadgeSelector(state),
|
||||
i18n: getIntl(state),
|
||||
theme: getTheme(state),
|
||||
selectedContacts,
|
||||
lookupConversationWithoutUuid,
|
||||
};
|
||||
};
|
||||
|
||||
const smart = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
export const SmartChooseGroupMembersModal = smart(ChooseGroupMembersModal);
|
49
ts/state/smart/ConfirmAdditionsModal.tsx
Normal file
49
ts/state/smart/ConfirmAdditionsModal.tsx
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
import { strictAssert } from '../../util/assert';
|
||||
|
||||
import type { StatePropsType } from '../../components/conversation/conversation-details/AddGroupMembersModal/ConfirmAdditionsModal';
|
||||
import { ConfirmAdditionsModal } from '../../components/conversation/conversation-details/AddGroupMembersModal/ConfirmAdditionsModal';
|
||||
import type { RequestState } from '../../components/conversation/conversation-details/util';
|
||||
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { getConversationByIdSelector } from '../selectors/conversations';
|
||||
|
||||
export type SmartConfirmAdditionsModalPropsType = {
|
||||
selectedConversationIds: ReadonlyArray<string>;
|
||||
groupTitle: string;
|
||||
makeRequest: () => void;
|
||||
onClose: () => void;
|
||||
requestState: RequestState;
|
||||
};
|
||||
|
||||
const mapStateToProps = (
|
||||
state: StateType,
|
||||
props: SmartConfirmAdditionsModalPropsType
|
||||
): StatePropsType => {
|
||||
const conversationSelector = getConversationByIdSelector(state);
|
||||
|
||||
const selectedContacts = props.selectedConversationIds.map(conversationId => {
|
||||
const convo = conversationSelector(conversationId);
|
||||
strictAssert(
|
||||
convo,
|
||||
'<SmartChooseGroupMemberModal> selected conversation not found'
|
||||
);
|
||||
return convo;
|
||||
});
|
||||
|
||||
return {
|
||||
...props,
|
||||
selectedContacts,
|
||||
i18n: getIntl(state),
|
||||
};
|
||||
};
|
||||
|
||||
const smart = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
export const SmartConfirmAdditionsModal = smart(ConfirmAdditionsModal);
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
|
@ -8,7 +9,6 @@ import { mapDispatchToProps } from '../actions';
|
|||
import type { StateProps } from '../../components/conversation/conversation-details/ConversationDetails';
|
||||
import { ConversationDetails } from '../../components/conversation/conversation-details/ConversationDetails';
|
||||
import {
|
||||
getCandidateContactsForNewGroup,
|
||||
getConversationByIdSelector,
|
||||
getConversationByUuidSelector,
|
||||
} from '../selectors/conversations';
|
||||
|
@ -24,6 +24,10 @@ import {
|
|||
import { assert } from '../../util/assert';
|
||||
import { SignalService as Proto } from '../../protobuf';
|
||||
import { getConversationColorAttributes } from '../../util/getConversationColorAttributes';
|
||||
import type { SmartChooseGroupMembersModalPropsType } from './ChooseGroupMembersModal';
|
||||
import { SmartChooseGroupMembersModal } from './ChooseGroupMembersModal';
|
||||
import type { SmartConfirmAdditionsModalPropsType } from './ConfirmAdditionsModal';
|
||||
import { SmartConfirmAdditionsModal } from './ConfirmAdditionsModal';
|
||||
|
||||
export type SmartConversationDetailsProps = {
|
||||
addMembers: (conversationIds: ReadonlyArray<string>) => Promise<void>;
|
||||
|
@ -56,6 +60,18 @@ export type SmartConversationDetailsProps = {
|
|||
|
||||
const ACCESS_ENUM = Proto.AccessControl.AccessRequired;
|
||||
|
||||
const renderChooseGroupMembersModal = (
|
||||
props: SmartChooseGroupMembersModalPropsType
|
||||
) => {
|
||||
return <SmartChooseGroupMembersModal {...props} />;
|
||||
};
|
||||
|
||||
const renderConfirmAdditionsModal = (
|
||||
props: SmartConfirmAdditionsModalPropsType
|
||||
) => {
|
||||
return <SmartConfirmAdditionsModal {...props} />;
|
||||
};
|
||||
|
||||
const mapStateToProps = (
|
||||
state: StateType,
|
||||
props: SmartConversationDetailsProps
|
||||
|
@ -69,7 +85,6 @@ const mapStateToProps = (
|
|||
|
||||
const canEditGroupInfo = Boolean(conversation.canEditGroupInfo);
|
||||
const isAdmin = Boolean(conversation.areWeAdmin);
|
||||
const candidateContactsToAdd = getCandidateContactsForNewGroup(state);
|
||||
|
||||
const hasGroupLink =
|
||||
Boolean(conversation.groupLink) &&
|
||||
|
@ -88,7 +103,6 @@ const mapStateToProps = (
|
|||
areWeASubscriber: getAreWeASubscriber(state),
|
||||
badges,
|
||||
canEditGroupInfo,
|
||||
candidateContactsToAdd,
|
||||
conversation: {
|
||||
...conversation,
|
||||
...getConversationColorAttributes(conversation),
|
||||
|
@ -102,6 +116,8 @@ const mapStateToProps = (
|
|||
hasGroupLink,
|
||||
isGroup: conversation.type === 'group',
|
||||
theme: getTheme(state),
|
||||
renderChooseGroupMembersModal,
|
||||
renderConfirmAdditionsModal,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
|||
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||
import { getAllComposableConversations } from '../selectors/conversations';
|
||||
import { getLinkPreview } from '../selectors/linkPreviews';
|
||||
import { getIntl, getTheme } from '../selectors/user';
|
||||
import { getIntl, getTheme, getRegionCode } from '../selectors/user';
|
||||
import { getEmojiSkinTone } from '../selectors/items';
|
||||
import { selectRecentEmojis } from '../selectors/emojis';
|
||||
import type { AttachmentType } from '../../types/Attachment';
|
||||
|
@ -69,6 +69,7 @@ const mapStateToProps = (
|
|||
skinTone,
|
||||
onTextTooLong,
|
||||
theme: getTheme(state),
|
||||
regionCode: getRegionCode(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import type { PropsType as LeftPanePropsType } from '../../components/LeftPane';
|
|||
import { LeftPane, LeftPaneMode } from '../../components/LeftPane';
|
||||
import type { StateType } from '../reducer';
|
||||
import { missingCaseError } from '../../util/missingCaseError';
|
||||
import { lookupConversationWithoutUuid } from '../../util/lookupConversationWithoutUuid';
|
||||
|
||||
import { ComposerStep, OneTimeModalState } from '../ducks/conversationsEnums';
|
||||
import {
|
||||
|
@ -32,11 +33,11 @@ import {
|
|||
getComposeGroupName,
|
||||
getComposerConversationSearchTerm,
|
||||
getComposerStep,
|
||||
getComposerUUIDFetchState,
|
||||
getComposeSelectedContacts,
|
||||
getFilteredCandidateContactsForNewGroup,
|
||||
getFilteredComposeContacts,
|
||||
getFilteredComposeGroups,
|
||||
getIsFetchingUsername,
|
||||
getLeftPaneLists,
|
||||
getMaximumGroupSizeModalState,
|
||||
getRecommendedGroupSizeModalState,
|
||||
|
@ -141,7 +142,7 @@ const getModeSpecificProps = (
|
|||
regionCode: getRegionCode(state),
|
||||
searchTerm: getComposerConversationSearchTerm(state),
|
||||
isUsernamesEnabled: getUsernamesEnabled(state),
|
||||
isFetchingUsername: getIsFetchingUsername(state),
|
||||
uuidFetchState: getComposerUUIDFetchState(state),
|
||||
};
|
||||
case ComposerStep.ChooseGroupMembers:
|
||||
return {
|
||||
|
@ -152,8 +153,10 @@ const getModeSpecificProps = (
|
|||
OneTimeModalState.Showing,
|
||||
isShowingMaximumGroupSizeModal:
|
||||
getMaximumGroupSizeModalState(state) === OneTimeModalState.Showing,
|
||||
regionCode: getRegionCode(state),
|
||||
searchTerm: getComposerConversationSearchTerm(state),
|
||||
selectedContacts: getComposeSelectedContacts(state),
|
||||
uuidFetchState: getComposerUUIDFetchState(state),
|
||||
};
|
||||
case ComposerStep.SetGroupMetadata:
|
||||
return {
|
||||
|
@ -192,6 +195,7 @@ const mapStateToProps = (state: StateType) => {
|
|||
renderUpdateDialog,
|
||||
renderCaptchaDialog,
|
||||
renderCrashReportDialog,
|
||||
lookupConversationWithoutUuid,
|
||||
theme: getTheme(state),
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue