Skip to content

Commit ac9dd3b

Browse files
committed
fix: description must be <= 200 chars in addition to being <= 600 bytes
1 parent 44ed80e commit ac9dd3b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ts/components/dialog/UpdateConversationDetailsDialog.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ import { UploadFirstImageButton } from '../buttons/avatar/UploadFirstImageButton
4545
import { sanitizeDisplayNameOrToast } from '../registration/utils';
4646
import { ProfileManager } from '../../session/profile_manager/ProfileManager';
4747

48+
/**
49+
* We want the description to be at most 200 visible characters, in addition
50+
* to being at most GROUP_INFO_DESCRIPTION_MAX_LENGTH bytes long.
51+
*
52+
*/
53+
const maxCharLength = 200;
54+
4855
function useNameErrorString({
4956
isMe,
5057
isPublic,
@@ -94,9 +101,13 @@ function useDescriptionErrorString({
94101
// description is always optional
95102
return '';
96103
}
104+
const charLength = newDescription?.length || 0;
97105
const byteLength = new TextEncoder().encode(newDescription).length;
98106

99-
if (byteLength <= LIBSESSION_CONSTANTS.GROUP_INFO_DESCRIPTION_MAX_LENGTH) {
107+
if (
108+
byteLength <= LIBSESSION_CONSTANTS.GROUP_INFO_DESCRIPTION_MAX_LENGTH &&
109+
charLength <= maxCharLength
110+
) {
100111
return '';
101112
}
102113
return isPublic

0 commit comments

Comments
 (0)