diff --git a/ts/components/dialog/edit-profile/EditProfileDialog.tsx b/ts/components/dialog/edit-profile/EditProfileDialog.tsx index 0a83498e9..fc705bb30 100644 --- a/ts/components/dialog/edit-profile/EditProfileDialog.tsx +++ b/ts/components/dialog/edit-profile/EditProfileDialog.tsx @@ -10,6 +10,7 @@ import { YourSessionIDPill, YourSessionIDSelectable } from '../../basic/YourSess import { useHotkey } from '../../../hooks/useHotkey'; import { useOurAvatarPath, useOurConversationUsername } from '../../../hooks/useParamSelector'; import { ProfileManager } from '../../../session/profile_manager/ProfileManager'; +import LIBSESSION_CONSTANTS from '../../../session/utils/libsession/libsession_constants'; import { editProfileModal, updateEditProfilePictureModel } from '../../../state/ducks/modalDialog'; import { SessionWrapperModal } from '../../SessionWrapperModal'; import { Flex } from '../../basic/Flex'; @@ -332,6 +333,7 @@ export const EditProfileDialog = () => { tabIndex={0} required={true} error={profileNameError} + maxLength={LIBSESSION_CONSTANTS.CONTACT_MAX_NAME_LENGTH} textSize={'xl'} centerText={true} inputRef={inputRef} diff --git a/ts/components/registration/stages/CreateAccount.tsx b/ts/components/registration/stages/CreateAccount.tsx index 4610f9d99..6a69498ee 100644 --- a/ts/components/registration/stages/CreateAccount.tsx +++ b/ts/components/registration/stages/CreateAccount.tsx @@ -6,6 +6,7 @@ import { mnDecode } from '../../../session/crypto/mnemonic'; import { ProfileManager } from '../../../session/profile_manager/ProfileManager'; import { StringUtils } from '../../../session/utils'; import { fromHex } from '../../../session/utils/String'; +import LIBSESSION_CONSTANTS from '../../../session/utils/libsession/libsession_constants'; import { trigger } from '../../../shims/events'; import { AccountCreation, @@ -164,6 +165,7 @@ export const CreateAccount = () => { }} onEnterPressed={signUpWithDetails} error={displayNameError} + maxLength={LIBSESSION_CONSTANTS.CONTACT_MAX_NAME_LENGTH} inputDataTestId="display-name-input" /> diff --git a/ts/components/registration/stages/RestoreAccount.tsx b/ts/components/registration/stages/RestoreAccount.tsx index 5ed1dd50a..059dec23b 100644 --- a/ts/components/registration/stages/RestoreAccount.tsx +++ b/ts/components/registration/stages/RestoreAccount.tsx @@ -7,6 +7,7 @@ import { ProfileManager } from '../../../session/profile_manager/ProfileManager' import { PromiseUtils } from '../../../session/utils'; import { TaskTimedOutError } from '../../../session/utils/Promise'; import { NotFoundError } from '../../../session/utils/errors'; +import LIBSESSION_CONSTANTS from '../../../session/utils/libsession/libsession_constants'; import { trigger } from '../../../shims/events'; import { AccountRestoration, @@ -253,6 +254,7 @@ export const RestoreAccount = () => { }} onEnterPressed={recoverAndFetchDisplayName} error={recoveryPasswordError} + maxLength={LIBSESSION_CONSTANTS.CONTACT_MAX_NAME_LENGTH} enableShowHideButton={true} showHideButtonAriaLabels={{ hide: 'Hide recovery password toggle', diff --git a/ts/session/utils/libsession/libsession_constants.ts b/ts/session/utils/libsession/libsession_constants.ts new file mode 100644 index 000000000..259bc6a48 --- /dev/null +++ b/ts/session/utils/libsession/libsession_constants.ts @@ -0,0 +1,12 @@ +import { CONSTANTS, ConstantsType } from 'libsession_util_nodejs'; + +const { CONTACT_MAX_NAME_LENGTH, BASE_GROUP_MAX_NAME_LENGTH, GROUP_INFO_MAX_NAME_LENGTH } = + CONSTANTS; + +const LIBSESSION_CONSTANTS: ConstantsType = { + CONTACT_MAX_NAME_LENGTH, + BASE_GROUP_MAX_NAME_LENGTH, + GROUP_INFO_MAX_NAME_LENGTH, +}; + +export default LIBSESSION_CONSTANTS;