Don't access RemoteConfig directly from 'dumb' components

This commit is contained in:
Scott Nonnenberg
2022-10-24 13:46:36 -07:00
committed by GitHub
parent e79380b37c
commit 0134990275
40 changed files with 352 additions and 353 deletions

View File

@@ -12,10 +12,6 @@ import {
} from '../../AddGroupMemberErrorDialog';
import type { SmartChooseGroupMembersModalPropsType } from '../../../state/smart/ChooseGroupMembersModal';
import type { SmartConfirmAdditionsModalPropsType } from '../../../state/smart/ConfirmAdditionsModal';
import {
getGroupSizeRecommendedLimit,
getGroupSizeHardLimit,
} from '../../../groups/limits';
import {
toggleSelectedContactForGroupAddition,
OneTimeModalState,
@@ -31,6 +27,8 @@ type PropsType = {
makeRequest: (conversationIds: ReadonlyArray<string>) => Promise<void>;
onClose: () => void;
requestState: RequestState;
maxGroupSize: number;
maxRecommendedGroupSize: number;
renderChooseGroupMembersModal: (
props: SmartChooseGroupMembersModalPropsType
@@ -46,6 +44,8 @@ enum Stage {
}
type StateType = {
maxGroupSize: number;
maxRecommendedGroupSize: number;
maximumGroupSizeModalState: OneTimeModalState;
recommendedGroupSizeModalState: OneTimeModalState;
searchTerm: string;
@@ -116,8 +116,8 @@ function reducer(
return {
...state,
...toggleSelectedContactForGroupAddition(action.conversationId, {
maxGroupSize: getMaximumNumberOfContacts(),
maxRecommendedGroupSize: getRecommendedMaximumNumberOfContacts(),
maxGroupSize: state.maxGroupSize,
maxRecommendedGroupSize: state.maxRecommendedGroupSize,
maximumGroupSizeModalState: state.maximumGroupSizeModalState,
numberOfContactsAlreadyInGroup: action.numberOfContactsAlreadyInGroup,
recommendedGroupSizeModalState: state.recommendedGroupSizeModalState,
@@ -141,13 +141,12 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
i18n,
onClose,
makeRequest,
maxGroupSize,
maxRecommendedGroupSize,
requestState,
renderChooseGroupMembersModal,
renderConfirmAdditionsModal,
}) => {
const maxGroupSize = getMaximumNumberOfContacts();
const maxRecommendedGroupSize = getRecommendedMaximumNumberOfContacts();
const numberOfContactsAlreadyInGroup = conversationIdsAlreadyInGroup.size;
const isGroupAlreadyFull = numberOfContactsAlreadyInGroup >= maxGroupSize;
const isGroupAlreadyOverRecommendedMaximum =
@@ -163,6 +162,8 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
},
dispatch,
] = useReducer(reducer, {
maxGroupSize,
maxRecommendedGroupSize,
maximumGroupSizeModalState: isGroupAlreadyFull
? OneTimeModalState.Showing
: OneTimeModalState.NeverShown,
@@ -260,11 +261,3 @@ export const AddGroupMembersModal: FunctionComponent<PropsType> = ({
throw missingCaseError(stage);
}
};
function getRecommendedMaximumNumberOfContacts(): number {
return getGroupSizeRecommendedLimit(151);
}
function getMaximumNumberOfContacts(): number {
return getGroupSizeHardLimit(1001);
}