Assume everyone is GV2-capable

This commit is contained in:
Evan Hahn 2022-03-04 13:48:44 -06:00 committed by GitHub
parent 0a52318be6
commit effe5aae6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 16 additions and 405 deletions

View File

@ -2393,20 +2393,6 @@
}
}
},
"chooseGroupMembers__cant-add-member__title": {
"message": "Cant add member",
"description": "Shown in the alert when you try to add someone who can't be added to a group"
},
"chooseGroupMembers__cant-add-member__body": {
"message": "\"$name$\" cant be added to the group because theyre using an old version of Signal. You can add them to the group after theyve updated Signal.",
"description": "Shown in the alert when you try to add someone who can't be added to a group",
"placeholders": {
"max": {
"content": "$1",
"example": "Jane Doe"
}
}
},
"setGroupMetadata__title": {
"message": "Name this group",
"description": "The title for the 'set group metadata' left pane screen"

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
@ -22,14 +22,6 @@ const defaultProps = {
onClose: action('onClose'),
};
story.add("Can't add a contact", () => (
<AddGroupMemberErrorDialog
{...defaultProps}
mode={AddGroupMemberErrorDialogMode.CantAddContact}
contact={{ title: 'Foo Bar' }}
/>
));
story.add('Maximum group size', () => (
<AddGroupMemberErrorDialog
{...defaultProps}

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { FunctionComponent, ReactNode } from 'react';
@ -6,21 +6,14 @@ import React from 'react';
import type { LocalizerType } from '../types/Util';
import { Alert } from './Alert';
import { Intl } from './Intl';
import { ContactName } from './conversation/ContactName';
import { missingCaseError } from '../util/missingCaseError';
export enum AddGroupMemberErrorDialogMode {
CantAddContact,
MaximumGroupSize,
RecommendedMaximumGroupSize,
}
type PropsDataType =
| {
mode: AddGroupMemberErrorDialogMode.CantAddContact;
contact: { title: string };
}
| {
mode: AddGroupMemberErrorDialogMode.MaximumGroupSize;
maximumNumberOfContacts: number;
@ -42,18 +35,6 @@ export const AddGroupMemberErrorDialog: FunctionComponent<PropsType> =
let title: string;
let body: ReactNode;
switch (props.mode) {
case AddGroupMemberErrorDialogMode.CantAddContact: {
const { contact } = props;
title = i18n('chooseGroupMembers__cant-add-member__title');
body = (
<Intl
i18n={i18n}
id="chooseGroupMembers__cant-add-member__body"
components={[<ContactName key="name" title={contact.title} />]}
/>
);
break;
}
case AddGroupMemberErrorDialogMode.MaximumGroupSize: {
const { maximumNumberOfContacts } = props;
title = i18n('chooseGroupMembers__maximum-group-size__title');

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useContext } from 'react';
@ -195,12 +195,6 @@ story.add('Contact checkboxes: disabled', () => (
isChecked: false,
disabledReason: ContactCheckboxDisabledReason.MaximumContactsSelected,
},
{
type: RowType.ContactCheckbox,
contact: defaultConversations[1],
isChecked: false,
disabledReason: ContactCheckboxDisabledReason.NotCapable,
},
{
type: RowType.ContactCheckbox,
contact: defaultConversations[2],

View File

@ -90,11 +90,9 @@ const defaultModeSpecificProps = {
const emptySearchResultsGroup = { isLoading: false, results: [] };
const useProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
cantAddContactToGroup: action('cantAddContactToGroup'),
clearConversationSearch: action('clearConversationSearch'),
clearGroupCreationError: action('clearGroupCreationError'),
clearSearch: action('clearSearch'),
closeCantAddContactToGroupModal: action('closeCantAddContactToGroupModal'),
closeMaximumGroupSizeModal: action('closeMaximumGroupSizeModal'),
closeRecommendedGroupSizeModal: action('closeRecommendedGroupSizeModal'),
composeDeleteAvatarFromDisk: action('composeDeleteAvatarFromDisk'),

View File

@ -95,11 +95,9 @@ export type PropsType = {
theme: ThemeType;
// Action Creators
cantAddContactToGroup: (conversationId: string) => void;
clearConversationSearch: () => void;
clearGroupCreationError: () => void;
clearSearch: () => void;
closeCantAddContactToGroupModal: () => void;
closeMaximumGroupSizeModal: () => void;
closeRecommendedGroupSizeModal: () => void;
createGroup: () => void;
@ -149,13 +147,11 @@ export type PropsType = {
};
export const LeftPane: React.FC<PropsType> = ({
cantAddContactToGroup,
challengeStatus,
crashReportCount,
clearConversationSearch,
clearGroupCreationError,
clearSearch,
closeCantAddContactToGroupModal,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
composeDeleteAvatarFromDisk,
@ -466,7 +462,6 @@ export const LeftPane: React.FC<PropsType> = ({
clearConversationSearch,
clearGroupCreationError,
clearSearch,
closeCantAddContactToGroupModal,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
composeDeleteAvatarFromDisk,
@ -607,9 +602,6 @@ export const LeftPane: React.FC<PropsType> = ({
case ContactCheckboxDisabledReason.MaximumContactsSelected:
// These are no-ops.
break;
case ContactCheckboxDisabledReason.NotCapable:
cantAddContactToGroup(conversationId);
break;
default:
throw missingCaseError(disabledReason);
}

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { FunctionComponent } from 'react';
@ -46,7 +46,6 @@ enum Stage {
}
type StateType = {
cantAddContactForModal: undefined | ConversationType;
maximumGroupSizeModalState: OneTimeModalState;
recommendedGroupSizeModalState: OneTimeModalState;
searchTerm: string;
@ -60,7 +59,6 @@ enum ActionType {
ConfirmAdds,
RemoveSelectedContact,
ReturnToContactChooser,
SetCantAddContactForModal,
ToggleSelectedContact,
UpdateSearchTerm,
}
@ -71,10 +69,6 @@ type Action =
| { type: ActionType.ConfirmAdds }
| { type: ActionType.ReturnToContactChooser }
| { type: ActionType.RemoveSelectedContact; conversationId: string }
| {
type: ActionType.SetCantAddContactForModal;
contact: undefined | ConversationType;
}
| {
type: ActionType.ToggleSelectedContact;
conversationId: string;
@ -118,11 +112,6 @@ function reducer(
action.conversationId
),
};
case ActionType.SetCantAddContactForModal:
return {
...state,
cantAddContactForModal: action.contact,
};
case ActionType.ToggleSelectedContact:
return {
...state,
@ -167,7 +156,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
const [
{
cantAddContactForModal,
maximumGroupSizeModalState,
recommendedGroupSizeModalState,
searchTerm,
@ -176,7 +164,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
},
dispatch,
] = useReducer(reducer, {
cantAddContactForModal: undefined,
maximumGroupSizeModalState: isGroupAlreadyFull
? OneTimeModalState.Showing
: OneTimeModalState.NeverShown,
@ -198,22 +185,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
selectedConversationIds
);
if (cantAddContactForModal) {
return (
<AddGroupMemberErrorDialog
contact={cantAddContactForModal}
i18n={i18n}
mode={AddGroupMemberErrorDialogMode.CantAddContact}
onClose={() => {
dispatch({
type: ActionType.SetCantAddContactForModal,
contact: undefined,
});
}}
/>
);
}
if (maximumGroupSizeModalState === OneTimeModalState.Showing) {
return (
<AddGroupMemberErrorDialog
@ -254,14 +225,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
conversationId,
});
};
const setCantAddContactForModal = (
contact: undefined | Readonly<ConversationType>
) => {
dispatch({
type: ActionType.SetCantAddContactForModal,
contact,
});
};
const setSearchTerm = (term: string) => {
dispatch({
type: ActionType.UpdateSearchTerm,
@ -280,7 +243,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
<ChooseGroupMembersModal
candidateContacts={candidateContacts}
confirmAdds={confirmAdds}
contactLookup={contactLookup}
conversationIdsAlreadyInGroup={conversationIdsAlreadyInGroup}
getPreferredBadge={getPreferredBadge}
i18n={i18n}
@ -289,7 +251,6 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
removeSelectedContact={removeSelectedContact}
searchTerm={searchTerm}
selectedContacts={selectedContacts}
setCantAddContactForModal={setCantAddContactForModal}
setSearchTerm={setSearchTerm}
theme={theme}
toggleSelectedContact={toggleSelectedContact}

View File

@ -8,7 +8,6 @@ import Measure from 'react-measure';
import type { LocalizerType, ThemeType } from '../../../../types/Util';
import { assert } from '../../../../util/assert';
import { getOwn } from '../../../../util/getOwn';
import { refMerger } from '../../../../util/refMerger';
import { useRestoreFocus } from '../../../../hooks/useRestoreFocus';
import { missingCaseError } from '../../../../util/missingCaseError';
@ -27,7 +26,6 @@ import { SearchInput } from '../../../SearchInput';
type PropsType = {
candidateContacts: ReadonlyArray<ConversationType>;
confirmAdds: () => void;
contactLookup: Record<string, ConversationType>;
conversationIdsAlreadyInGroup: Set<string>;
getPreferredBadge: PreferredBadgeSelectorType;
i18n: LocalizerType;
@ -36,9 +34,6 @@ type PropsType = {
removeSelectedContact: (_: string) => void;
searchTerm: string;
selectedContacts: ReadonlyArray<ConversationType>;
setCantAddContactForModal: (
_: Readonly<undefined | ConversationType>
) => void;
setSearchTerm: (_: string) => void;
theme: ThemeType;
toggleSelectedContact: (conversationId: string) => void;
@ -48,7 +43,6 @@ type PropsType = {
export const ChooseGroupMembersModal: FunctionComponent<PropsType> = ({
candidateContacts,
confirmAdds,
contactLookup,
conversationIdsAlreadyInGroup,
getPreferredBadge,
i18n,
@ -57,7 +51,6 @@ export const ChooseGroupMembersModal: FunctionComponent<PropsType> = ({
removeSelectedContact,
searchTerm,
selectedContacts,
setCantAddContactForModal,
setSearchTerm,
theme,
toggleSelectedContact,
@ -111,8 +104,6 @@ export const ChooseGroupMembersModal: FunctionComponent<PropsType> = ({
disabledReason = ContactCheckboxDisabledReason.AlreadyAdded;
} else if (hasSelectedMaximumNumberOfContacts && !isSelected) {
disabledReason = ContactCheckboxDisabledReason.MaximumContactsSelected;
} else if (!contact.isGroupV2Capable) {
disabledReason = ContactCheckboxDisabledReason.NotCapable;
}
return {
@ -212,15 +203,6 @@ export const ChooseGroupMembersModal: FunctionComponent<PropsType> = ({
case ContactCheckboxDisabledReason.MaximumContactsSelected:
// These are no-ops.
break;
case ContactCheckboxDisabledReason.NotCapable: {
const contact = getOwn(contactLookup, conversationId);
assert(
contact,
'Contact was not in lookup; not showing modal'
);
setCantAddContactForModal(contact);
break;
}
default:
throw missingCaseError(disabledReason);
}

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { FunctionComponent, ReactNode } from 'react';
@ -18,7 +18,6 @@ export enum ContactCheckboxDisabledReason {
// We start the enum at 1 because the default starting value of 0 is falsy.
AlreadyAdded = 1,
MaximumContactsSelected,
NotCapable,
}
export type PropsDataType = {

View File

@ -25,7 +25,6 @@ import {
export type LeftPaneChooseGroupMembersPropsType = {
candidateContacts: ReadonlyArray<ConversationType>;
cantAddContactForModal: undefined | ConversationType;
isShowingRecommendedGroupSizeModal: boolean;
isShowingMaximumGroupSizeModal: boolean;
searchTerm: string;
@ -35,10 +34,6 @@ export type LeftPaneChooseGroupMembersPropsType = {
export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneChooseGroupMembersPropsType> {
private readonly candidateContacts: ReadonlyArray<ConversationType>;
private readonly cantAddContactForModal:
| undefined
| Readonly<{ title: string }>;
private readonly isShowingMaximumGroupSizeModal: boolean;
private readonly isShowingRecommendedGroupSizeModal: boolean;
@ -51,7 +46,6 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
constructor({
candidateContacts,
cantAddContactForModal,
isShowingMaximumGroupSizeModal,
isShowingRecommendedGroupSizeModal,
searchTerm,
@ -60,7 +54,6 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
super();
this.candidateContacts = candidateContacts;
this.cantAddContactForModal = cantAddContactForModal;
this.isShowingMaximumGroupSizeModal = isShowingMaximumGroupSizeModal;
this.isShowingRecommendedGroupSizeModal =
isShowingRecommendedGroupSizeModal;
@ -127,13 +120,11 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
}
override getPreRowsNode({
closeCantAddContactToGroupModal,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
i18n,
removeSelectedContact,
}: Readonly<{
closeCantAddContactToGroupModal: () => unknown;
closeMaximumGroupSizeModal: () => unknown;
closeRecommendedGroupSizeModal: () => unknown;
i18n: LocalizerType;
@ -158,15 +149,6 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
onClose={closeRecommendedGroupSizeModal}
/>
);
} else if (this.cantAddContactForModal) {
modalNode = (
<AddGroupMemberErrorDialog
i18n={i18n}
contact={this.cantAddContactForModal}
mode={AddGroupMemberErrorDialogMode.CantAddContact}
onClose={closeCantAddContactToGroupModal}
/>
);
}
return (
@ -254,15 +236,10 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
}
const isChecked = this.selectedConversationIdsSet.has(contact.id);
let disabledReason: undefined | ContactCheckboxDisabledReason;
if (!isChecked) {
if (this.hasSelectedMaximumNumberOfContacts()) {
disabledReason = ContactCheckboxDisabledReason.MaximumContactsSelected;
} else if (!contact.isGroupV2Capable) {
disabledReason = ContactCheckboxDisabledReason.NotCapable;
}
}
const disabledReason =
!isChecked && this.hasSelectedMaximumNumberOfContacts()
? ContactCheckboxDisabledReason.MaximumContactsSelected
: undefined;
return {
type: RowType.ContactCheckbox,

View File

@ -62,7 +62,6 @@ export abstract class LeftPaneHelper<T> {
clearConversationSearch: () => unknown;
clearGroupCreationError: () => void;
clearSearch: () => unknown;
closeCantAddContactToGroupModal: () => unknown;
closeMaximumGroupSizeModal: () => unknown;
closeRecommendedGroupSizeModal: () => unknown;
composeDeleteAvatarFromDisk: DeleteAvatarFromDiskActionType;

View File

@ -638,22 +638,10 @@ export async function buildAddMembersChange(
}
// Refresh our local data to be sure
if (
!contact.get('capabilities')?.gv2 ||
!contact.get('profileKey') ||
!contact.get('profileKeyCredential')
) {
if (!contact.get('profileKey') || !contact.get('profileKeyCredential')) {
await contact.getProfiles();
}
if (!contact.get('capabilities')?.gv2) {
assert(
false,
`buildAddMembersChange/${logId}: member is missing GV2 capability; skipping`
);
return;
}
const profileKey = contact.get('profileKey');
const profileKeyCredential = contact.get('profileKeyCredential');
@ -1511,22 +1499,10 @@ export async function createGroupV2({
}
// Refresh our local data to be sure
if (
!contact.get('capabilities')?.gv2 ||
!contact.get('profileKey') ||
!contact.get('profileKeyCredential')
) {
if (!contact.get('profileKey') || !contact.get('profileKeyCredential')) {
await contact.getProfiles();
}
if (!contact.get('capabilities')?.gv2) {
assert(
false,
`createGroupV2/${logId}: member is missing GV2 capability; skipping`
);
return;
}
if (contact.get('profileKey') && contact.get('profileKeyCredential')) {
membersV2.push({
uuid: contactUuid,
@ -1836,22 +1812,14 @@ export async function getGroupMigrationMembers(
// Refresh our local data to be sure
if (
!capabilities ||
!capabilities.gv2 ||
!capabilities['gv1-migration'] ||
!capabilities?.['gv1-migration'] ||
!contact.get('profileKeyCredential')
) {
await contact.getProfiles();
}
capabilities = contact.get('capabilities');
if (!capabilities || !capabilities.gv2) {
log.warn(
`getGroupMigrationMembers/${logId}: membersV2 - member ${e164} is missing gv2 capability, skipping.`
);
return null;
}
if (!capabilities || !capabilities['gv1-migration']) {
if (!capabilities?.['gv1-migration']) {
log.warn(
`getGroupMigrationMembers/${logId}: membersV2 - member ${e164} is missing gv1-migration capability, skipping.`
);
@ -1916,14 +1884,7 @@ export async function getGroupMigrationMembers(
}
const capabilities = contact.get('capabilities');
if (!capabilities || !capabilities.gv2) {
log.warn(
`getGroupMigrationMembers/${logId}: pendingMembersV2 - member ${e164} is missing gv2 capability, skipping.`
);
droppedGV2MemberIds.push(conversationId);
return null;
}
if (!capabilities || !capabilities['gv1-migration']) {
if (!capabilities?.['gv1-migration']) {
log.warn(
`getGroupMigrationMembers/${logId}: pendingMembersV2 - member ${e164} is missing gv1-migration capability, skipping.`
);

View File

@ -1815,9 +1815,6 @@ export class ConversationModel extends window.Backbone
isBlocked: this.isBlocked(),
isMe: isMe(this.attributes),
isGroupV1AndDisabled: this.isGroupV1AndDisabled(),
isGroupV2Capable: isDirectConversation(this.attributes)
? Boolean(this.get('capabilities')?.gv2)
: undefined,
isPinned: this.get('isPinned'),
isUntrusted: this.isUntrusted(),
isVerified: this.isVerified(),

View File

@ -133,7 +133,6 @@ export type ConversationType = {
isArchived?: boolean;
isBlocked?: boolean;
isGroupV1AndDisabled?: boolean;
isGroupV2Capable?: boolean;
isPinned?: boolean;
isUntrusted?: boolean;
isVerified?: boolean;
@ -298,7 +297,6 @@ type ComposerStateType =
| ({
step: ComposerStep.ChooseGroupMembers;
searchTerm: string;
cantAddContactIdForModal: undefined | string;
} & ComposerGroupCreationState)
| ({
step: ComposerStep.SetGroupMetadata;
@ -402,12 +400,6 @@ export type CancelVerificationDataByConversationActionType = {
canceledAt: number;
};
};
type CantAddContactToGroupActionType = {
type: 'CANT_ADD_CONTACT_TO_GROUP';
payload: {
conversationId: string;
};
};
type ClearGroupCreationErrorActionType = { type: 'CLEAR_GROUP_CREATION_ERROR' };
type ClearInvitedUuidsForNewlyCreatedGroupActionType = {
type: 'CLEAR_INVITED_UUIDS_FOR_NEWLY_CREATED_GROUP';
@ -421,9 +413,6 @@ type ClearCancelledVerificationActionType = {
conversationId: string;
};
};
type CloseCantAddContactToGroupModalActionType = {
type: 'CLOSE_CANT_ADD_CONTACT_TO_GROUP_MODAL';
};
type CloseContactSpoofingReviewActionType = {
type: 'CLOSE_CONTACT_SPOOFING_REVIEW';
};
@ -736,14 +725,12 @@ type ReplaceAvatarsActionType = {
};
export type ConversationActionType =
| CancelVerificationDataByConversationActionType
| CantAddContactToGroupActionType
| ClearCancelledVerificationActionType
| ClearVerificationDataByConversationActionType
| ClearGroupCreationErrorActionType
| ClearInvitedUuidsForNewlyCreatedGroupActionType
| ClearSelectedMessageActionType
| ClearUnreadMetricsActionType
| CloseCantAddContactToGroupModalActionType
| CloseContactSpoofingReviewActionType
| CloseMaximumGroupSizeModalActionType
| CloseRecommendedGroupSizeModalActionType
@ -801,14 +788,12 @@ export type ConversationActionType =
export const actions = {
cancelConversationVerification,
cantAddContactToGroup,
clearCancelledConversationVerification,
clearGroupCreationError,
clearInvitedUuidsForNewlyCreatedGroup,
clearSelectedMessage,
clearUnreadMetrics,
clearUsernameSave,
closeCantAddContactToGroupModal,
closeContactSpoofingReview,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
@ -1379,14 +1364,6 @@ function composeReplaceAvatar(
};
}
function cantAddContactToGroup(
conversationId: string
): CantAddContactToGroupActionType {
return {
type: 'CANT_ADD_CONTACT_TO_GROUP',
payload: { conversationId },
};
}
function setPreJoinConversation(
data: PreJoinConversationType | undefined
): SetPreJoinConversationActionType {
@ -1722,9 +1699,6 @@ function clearUnreadMetrics(
},
};
}
function closeCantAddContactToGroupModal(): CloseCantAddContactToGroupModalActionType {
return { type: 'CLOSE_CANT_ADD_CONTACT_TO_GROUP_MODAL' };
}
function closeContactSpoofingReview(): CloseContactSpoofingReviewActionType {
return { type: 'CLOSE_CONTACT_SPOOFING_REVIEW' };
}
@ -2230,21 +2204,6 @@ export function reducer(
};
}
if (action.type === 'CANT_ADD_CONTACT_TO_GROUP') {
const { composer } = state;
if (composer?.step !== ComposerStep.ChooseGroupMembers) {
assert(false, "Can't update modal in this composer step. Doing nothing");
return state;
}
return {
...state,
composer: {
...composer,
cantAddContactIdForModal: action.payload.conversationId,
},
};
}
if (action.type === 'CLEAR_INVITED_UUIDS_FOR_NEWLY_CREATED_GROUP') {
return omit(state, 'invitedUuidsForNewlyCreatedGroup');
}
@ -2267,24 +2226,6 @@ export function reducer(
};
}
if (action.type === 'CLOSE_CANT_ADD_CONTACT_TO_GROUP_MODAL') {
const { composer } = state;
if (composer?.step !== ComposerStep.ChooseGroupMembers) {
assert(
false,
"Can't close the modal in this composer step. Doing nothing"
);
return state;
}
return {
...state,
composer: {
...composer,
cantAddContactIdForModal: undefined,
},
};
}
if (action.type === 'CLOSE_CONTACT_SPOOFING_REVIEW') {
return omit(state, 'contactSpoofingReview');
}
@ -3139,7 +3080,6 @@ export function reducer(
step: ComposerStep.ChooseGroupMembers,
searchTerm: '',
selectedConversationIds,
cantAddContactIdForModal: undefined,
recommendedGroupSizeModalState,
maximumGroupSizeModalState,
groupName,

View File

@ -535,28 +535,6 @@ export const getFilteredCandidateContactsForNewGroup = createSelector(
filterAndSortConversationsByTitle
);
export const getCantAddContactForModal = createSelector(
getConversationLookup,
getComposerState,
(conversationLookup, composerState): undefined | ConversationType => {
if (composerState?.step !== ComposerStep.ChooseGroupMembers) {
return undefined;
}
const conversationId = composerState.cantAddContactIdForModal;
if (!conversationId) {
return undefined;
}
const result = getOwn(conversationLookup, conversationId);
assert(
result,
'getCantAddContactForModal: failed to look up conversation by ID; returning undefined'
);
return result;
}
);
const getGroupCreationComposerState = createSelector(
getComposerState,
(

View File

@ -26,7 +26,6 @@ import {
getUsernamesEnabled,
} from '../selectors/items';
import {
getCantAddContactForModal,
getComposeAvatarData,
getComposeGroupAvatar,
getComposeGroupExpireTimer,
@ -148,7 +147,6 @@ const getModeSpecificProps = (
return {
mode: LeftPaneMode.ChooseGroupMembers,
candidateContacts: getFilteredCandidateContactsForNewGroup(state),
cantAddContactForModal: getCantAddContactForModal(state),
isShowingRecommendedGroupSizeModal:
getRecommendedGroupSizeModalState(state) ===
OneTimeModalState.Showing,

View File

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { ComposerStep } from '../../state/ducks/conversationsEnums';
@ -13,7 +13,6 @@ export const defaultStartDirectConversationComposerState = {
export const defaultChooseGroupMembersComposerState = {
step: ComposerStep.ChooseGroupMembers as const,
searchTerm: '',
cantAddContactIdForModal: undefined,
groupAvatar: undefined,
groupName: '',
groupExpireTimer: 0,

View File

@ -1,4 +1,4 @@
// Copyright 2020-2021 Signal Messenger, LLC
// Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { v4 as generateUuid } from 'uuid';
@ -330,7 +330,6 @@ export function getDefaultConversation(
color: getRandomColor(),
firstName,
id: generateUuid(),
isGroupV2Capable: true,
isMe: false,
lastUpdated: Date.now(),
markedUnread: Boolean(overrideProps.markedUnread),

View File

@ -18,7 +18,6 @@ import {
_getLeftPaneLists,
getAllComposableConversations,
getCandidateContactsForNewGroup,
getCantAddContactForModal,
getComposableContacts,
getComposableGroups,
getComposeGroupAvatar,
@ -1162,53 +1161,6 @@ describe('both/state/selectors/conversations', () => {
});
});
describe('#getCantAddContactForModal', () => {
it('returns undefined if not in the "choose group members" composer step', () => {
assert.isUndefined(getCantAddContactForModal(getEmptyRootState()));
assert.isUndefined(
getCantAddContactForModal({
...getEmptyRootState(),
conversations: {
...getEmptyState(),
composer: defaultStartDirectConversationComposerState,
},
})
);
});
it("returns undefined if there's no contact marked", () => {
assert.isUndefined(
getCantAddContactForModal({
...getEmptyRootState(),
conversations: {
...getEmptyState(),
composer: defaultChooseGroupMembersComposerState,
},
})
);
});
it('returns the marked contact', () => {
const conversation = makeConversation('abc123');
assert.deepEqual(
getCantAddContactForModal({
...getEmptyRootState(),
conversations: {
...getEmptyState(),
conversationLookup: { abc123: conversation },
composer: {
...defaultChooseGroupMembersComposerState,
cantAddContactIdForModal: 'abc123',
},
},
}),
conversation
);
});
});
describe('#getComposerConversationSearchTerm', () => {
it("returns the composer's contact search term", () => {
assert.strictEqual(

View File

@ -47,10 +47,8 @@ import {
import { updateRemoteConfig } from '../../../test-both/helpers/RemoteConfigStub';
const {
cantAddContactToGroup,
clearGroupCreationError,
clearInvitedUuidsForNewlyCreatedGroup,
closeCantAddContactToGroupModal,
closeContactSpoofingReview,
closeMaximumGroupSizeModal,
closeRecommendedGroupSizeModal,
@ -461,22 +459,6 @@ describe('both/state/ducks/conversations', () => {
});
});
describe('CANT_ADD_CONTACT_TO_GROUP', () => {
it('marks the conversation ID as "cannot add"', () => {
const state = {
...getEmptyState(),
composer: defaultChooseGroupMembersComposerState,
};
const action = cantAddContactToGroup('abc123');
const result = reducer(state, action);
assert(
result.composer?.step === ComposerStep.ChooseGroupMembers &&
result.composer.cantAddContactIdForModal === 'abc123'
);
});
});
describe('CLEAR_GROUP_CREATION_ERROR', () => {
it('clears the group creation error', () => {
const state = {
@ -512,26 +494,6 @@ describe('both/state/ducks/conversations', () => {
});
});
describe('CLOSE_CANT_ADD_CONTACT_TO_GROUP_MODAL', () => {
it('closes the "cannot add contact" modal"', () => {
const state = {
...getEmptyState(),
composer: {
...defaultChooseGroupMembersComposerState,
cantAddContactIdForModal: 'abc123',
},
};
const action = closeCantAddContactToGroupModal();
const result = reducer(state, action);
assert(
result.composer?.step === ComposerStep.ChooseGroupMembers &&
result.composer.cantAddContactIdForModal === undefined,
'Expected the contact ID to be cleared'
);
});
});
describe('CLOSE_CONTACT_SPOOFING_REVIEW', () => {
it('closes the contact spoofing review modal if it was open', () => {
const state = {

View File

@ -14,7 +14,6 @@ import { updateRemoteConfig } from '../../../test-both/helpers/RemoteConfigStub'
describe('LeftPaneChooseGroupMembersHelper', () => {
const defaults = {
candidateContacts: [],
cantAddContactForModal: undefined,
isShowingRecommendedGroupSizeModal: false,
isShowingMaximumGroupSizeModal: false,
searchTerm: '',
@ -163,39 +162,5 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
disabledReason: undefined,
});
});
it("disables contacts that aren't GV2-capable, unless they are already selected somehow", () => {
const candidateContacts = [
{ ...getDefaultConversation(), isGroupV2Capable: false },
{ ...getDefaultConversation(), isGroupV2Capable: undefined },
{ ...getDefaultConversation(), isGroupV2Capable: false },
];
const helper = new LeftPaneChooseGroupMembersHelper({
...defaults,
candidateContacts,
searchTerm: 'foo bar',
selectedContacts: [candidateContacts[2]],
});
assert.deepEqual(helper.getRow(1), {
type: RowType.ContactCheckbox,
contact: candidateContacts[0],
isChecked: false,
disabledReason: ContactCheckboxDisabledReason.NotCapable,
});
assert.deepEqual(helper.getRow(2), {
type: RowType.ContactCheckbox,
contact: candidateContacts[1],
isChecked: false,
disabledReason: ContactCheckboxDisabledReason.NotCapable,
});
assert.deepEqual(helper.getRow(3), {
type: RowType.ContactCheckbox,
contact: candidateContacts[2],
isChecked: true,
disabledReason: undefined,
});
});
});
});

View File

@ -658,7 +658,6 @@ export type WebAPIConnectType = {
export type CapabilitiesType = {
announcementGroup: boolean;
gv2: boolean;
'gv1-migration': boolean;
senderKey: boolean;
changeNumber: boolean;