From b236f274c3524a0e091a12741b6b3855ae9283ef Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 5 Jun 2026 23:17:29 +0300 Subject: [PATCH] [Chat] Enforce limits for group size (#10753) --- .../dialogs/SearchablePeopleList.tsx | 1 - src/components/dms/AddMembersFlow.tsx | 11 ++++ src/components/dms/InitiateChatFlow.tsx | 34 ++++++++++- .../dms/components/GroupChatProfileCard.tsx | 58 +++++++++++-------- src/lib/constants.ts | 2 + .../Messages/ConversationSettings/prompts.tsx | 35 +++++++++-- 6 files changed, 109 insertions(+), 32 deletions(-) diff --git a/src/components/dialogs/SearchablePeopleList.tsx b/src/components/dialogs/SearchablePeopleList.tsx index 614234c17f..cc07900bea 100644 --- a/src/components/dialogs/SearchablePeopleList.tsx +++ b/src/components/dialogs/SearchablePeopleList.tsx @@ -667,7 +667,6 @@ function SearchInput({ /> - + + {groupNameTooLong ? ( + + + Group name is too long. The maximum number of characters + is {MAX_GROUP_NAME_GRAPHEME_LENGTH}. + + + ) : null} ) : ( - - - - - - {enabled ? ( - - ) : ( - - {handle} can’t be added - - )} + {({disabled, selected}) => ( + <> + + + + + + {enabled ? ( + + ) : ( + + {handle} can’t be added + + )} + + - - - {enabled ? : null} + {enabled ? : null} + + )} ) } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 13ae162a85..91d1319c6b 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -67,6 +67,8 @@ export const MAX_DRAFT_GRAPHEME_LENGTH = 1000 export const MAX_DM_GRAPHEME_LENGTH = 1000 +export const MAX_GROUP_NAME_GRAPHEME_LENGTH = 50 + // Recommended is 100 per: https://www.w3.org/WAI/GL/WCAG20/tests/test3.html // but increasing limit per user feedback export const MAX_ALT_TEXT = 2000 diff --git a/src/screens/Messages/ConversationSettings/prompts.tsx b/src/screens/Messages/ConversationSettings/prompts.tsx index f5b980b990..e8b594c0bd 100644 --- a/src/screens/Messages/ConversationSettings/prompts.tsx +++ b/src/screens/Messages/ConversationSettings/prompts.tsx @@ -1,10 +1,13 @@ import {View} from 'react-native' import {Trans, useLingui} from '@lingui/react/macro' -import {atoms as a} from '#/alf' +import {MAX_GROUP_NAME_GRAPHEME_LENGTH} from '#/lib/constants' +import {isOverMaxGraphemeCount} from '#/lib/strings/helpers' +import {atoms as a, useTheme} from '#/alf' import type * as Dialog from '#/components/Dialog' import * as TextField from '#/components/forms/TextField' import * as Prompt from '#/components/Prompt' +import {Text} from '#/components/Typography' export function EditNamePrompt({ control, @@ -17,8 +20,14 @@ export function EditNamePrompt({ onChangeText: (value: string) => void onConfirm: () => void }) { + const t = useTheme() const {t: l} = useLingui() + const nameTooLong = isOverMaxGraphemeCount({ + text: value, + maxCount: MAX_GROUP_NAME_GRAPHEME_LENGTH, + }) + return ( <> @@ -27,7 +36,7 @@ export function EditNamePrompt({ Edit group name - + + {nameTooLong ? ( + + + Group name is too long. The maximum number of characters is{' '} + {MAX_GROUP_NAME_GRAPHEME_LENGTH}. + + + ) : null} - +