diff --git a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx index abed3a3d97..01b51091e7 100644 --- a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx +++ b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx @@ -10,7 +10,7 @@ import { LoadingButton } from '../ui/LoadingButton/LoadingButton' import { TextInput } from '../../forms/components/textInput' import { userNameField } from '../../forms/fields/createUserFields' import { parseName } from '@quiet/common' -import { User } from '@quiet/types' +import { UserData } from '@quiet/types' const PREFIX = 'CreateUsernameComponent-' @@ -150,7 +150,7 @@ export interface CreateUsernameComponentProps { certificateRegistrationError?: string certificate?: string | null handleClose: () => void - allUsers?: Record + registeredUsers?: Record currentUsername?: string variant?: UsernameVariant } @@ -162,7 +162,7 @@ export const CreateUsernameComponent: React.FC = ( certificate, handleClose, currentUsername, - allUsers, + registeredUsers, variant = UsernameVariant.NEW, }) => { const isNewUser = variant === UsernameVariant.NEW @@ -209,8 +209,8 @@ export const CreateUsernameComponent: React.FC = ( const parsedName = parseName(name) setUserName(parsedName) setParsedNameDiffers(name !== parsedName) - if (allUsers && !isNewUser) { - const allUsersArr = Object.values(allUsers).map(user => user.username) + if (registeredUsers && !isNewUser) { + const allUsersArr = Object.values(registeredUsers).map(user => user.username) if (allUsersArr.includes(name)) { setError('userName', { message: `${name} is already taken` }) } diff --git a/packages/desktop/src/renderer/components/widgets/usernameTakenModal/UsernameTakenModal.container.tsx b/packages/desktop/src/renderer/components/widgets/usernameTakenModal/UsernameTakenModal.container.tsx index ebea1c326d..f9f27810e5 100644 --- a/packages/desktop/src/renderer/components/widgets/usernameTakenModal/UsernameTakenModal.container.tsx +++ b/packages/desktop/src/renderer/components/widgets/usernameTakenModal/UsernameTakenModal.container.tsx @@ -1,4 +1,4 @@ -import { ErrorCodes, ErrorMessages, errors, identity, SocketActionTypes, users } from '@quiet/state-manager' +import { identity, users } from '@quiet/state-manager' import React, { useCallback, useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' import { useModal } from '../../../containers/hooks' @@ -10,7 +10,7 @@ const UsernameTakenModalContainer = () => { const isUsernameTaken = useSelector(identity.selectors.usernameTaken) const usernameTakenModal = useModal(ModalName.usernameTakenModal) - const allUsers = useSelector(users.selectors.allUsers) + const registeredUsers = useSelector(users.selectors.certificatesMapping) const user = useSelector(identity.selectors.currentIdentity) const registerUsername = useCallback( @@ -40,7 +40,7 @@ const UsernameTakenModalContainer = () => { currentUsername={user?.nickname} registerUsername={registerUsername} variant={UsernameVariant.TAKEN} - allUsers={allUsers} + registeredUsers={registeredUsers} {...usernameTakenModal} /> ) diff --git a/packages/state-manager/src/sagas/identity/identity.selectors.ts b/packages/state-manager/src/sagas/identity/identity.selectors.ts index ec6b1a679e..208b8f7c92 100644 --- a/packages/state-manager/src/sagas/identity/identity.selectors.ts +++ b/packages/state-manager/src/sagas/identity/identity.selectors.ts @@ -3,7 +3,7 @@ import { createSelector } from '@reduxjs/toolkit' import { identityAdapter } from './identity.adapter' import { type CreatedSelectors, type StoreState } from '../store.types' import { communitiesSelectors, selectCommunities } from '../communities/communities.selectors' -import { certificatesMapping, csrsMapping } from '../users/users.selectors' +import { certificatesMapping } from '../users/users.selectors' const identitySlice: CreatedSelectors[StoreKeys.Identity] = (state: StoreState) => state[StoreKeys.Identity]