Skip to content

Commit 33588d0

Browse files
committed
fix: name & description for convo details are bytelength, not char
1 parent 952f87c commit 33588d0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ts/components/dialog/UpdateConversationDetailsDialog.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,24 @@ function useNameErrorString({
5555
isPublic: boolean;
5656
isMe: boolean;
5757
}) {
58+
const byteLength = new TextEncoder().encode(newName).length;
5859
if (isMe) {
5960
return !newName
6061
? tr('displayNameErrorDescription')
61-
: newName.length > LIBSESSION_CONSTANTS.CONTACT_MAX_NAME_LENGTH
62+
: byteLength > LIBSESSION_CONSTANTS.CONTACT_MAX_NAME_LENGTH
6263
? tr('displayNameErrorDescriptionShorter')
6364
: '';
6465
}
6566
if (isPublic) {
6667
return !newName
6768
? tr('communityNameEnterPlease')
68-
: newName.length > LIBSESSION_CONSTANTS.BASE_GROUP_MAX_NAME_LENGTH
69+
: byteLength > LIBSESSION_CONSTANTS.BASE_GROUP_MAX_NAME_LENGTH
6970
? tr('updateCommunityInformationEnterShorterName')
7071
: '';
7172
}
7273
return !newName
7374
? tr('groupNameEnterPlease')
74-
: newName.length > LIBSESSION_CONSTANTS.BASE_GROUP_MAX_NAME_LENGTH
75+
: byteLength > LIBSESSION_CONSTANTS.BASE_GROUP_MAX_NAME_LENGTH
7576
? tr('groupNameEnterShorter')
7677
: '';
7778
}
@@ -94,7 +95,9 @@ function useDescriptionErrorString({
9495
// description is always optional
9596
return '';
9697
}
97-
if (newDescription.length <= LIBSESSION_CONSTANTS.GROUP_INFO_DESCRIPTION_MAX_LENGTH) {
98+
const byteLength = new TextEncoder().encode(newDescription).length;
99+
100+
if (byteLength <= LIBSESSION_CONSTANTS.GROUP_INFO_DESCRIPTION_MAX_LENGTH) {
98101
return '';
99102
}
100103
return isPublic

0 commit comments

Comments
 (0)