From f56079c7aa2164e2bebd2cdc8eb7e2e5d6bce335 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 12:08:27 +0100 Subject: [PATCH 1/7] fix: ask push notification runtime permission on Android --- .../java/com/quietmobile/MainActivity.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java b/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java index 4670677df5..f5f696f3ca 100644 --- a/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java +++ b/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java @@ -1,10 +1,19 @@ package com.quietmobile; +import android.Manifest; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; +import android.util.AttributeSet; import android.util.Log; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import com.facebook.react.ReactActivity; @@ -110,6 +119,22 @@ protected void onCreate(Bundle savedInstanceState) { } } + @Nullable + @Override + public View onCreateView(@NonNull String name, @NonNull Context context, @NonNull AttributeSet attrs) { + checkNotificationsPermission(); + return super.onCreateView(name, context, attrs); + } + + private static final int NOTIFICATION_PERMISSION_REQUEST_CODE = 200; + + private void checkNotificationsPermission() { + if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + // Requesting the permission + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, NOTIFICATION_PERMISSION_REQUEST_CODE); + } + } + @Override protected void onResume() { super.onResume(); From 854554c9c5d4ea9abaac78a3e3e0f450f486a011 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 12:10:41 +0100 Subject: [PATCH 2/7] chore: update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4832512f..f8e8fa3c0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ [2.1.0] - unreleased +* Ask push notifications runtime permission on Android app start + * Fix for multiplicating "welcome" messages when joining a community [2.0.0] From b1a2204043427a60ff3e50d95f68ef892e75c011 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 12:13:19 +0100 Subject: [PATCH 3/7] fix: mobile e2e yaml syntax --- .github/workflows/e2e-android.yml | 5 ++++- .github/workflows/e2e-ios.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-android.yml b/.github/workflows/e2e-android.yml index 4b5ec1ee9b..86b8a09bd7 100644 --- a/.github/workflows/e2e-android.yml +++ b/.github/workflows/e2e-android.yml @@ -2,7 +2,10 @@ name: E2E Android on: push: - paths: [packages/mobile/**, packages/backend/**, packages/state-manager/**], + paths: + - packages/mobile/** + - packages/backend/** + - packages/state-manager/** jobs: detox-android: diff --git a/.github/workflows/e2e-ios.yml b/.github/workflows/e2e-ios.yml index e9a527c994..34ad277d79 100644 --- a/.github/workflows/e2e-ios.yml +++ b/.github/workflows/e2e-ios.yml @@ -2,7 +2,10 @@ name: E2E iOS on: push: - paths: [packages/mobile/**, packages/backend/**, packages/state-manager/**], + paths: + - packages/mobile/** + - packages/backend/** + - packages/state-manager/** jobs: detox-ios: From 0b150288350575d13c41eb489bc3717f0add4037 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 12:14:48 +0100 Subject: [PATCH 4/7] chore: trigger mobile workflows --- .../src/store/init/startConnection/startConnection.saga.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts index 7911de1d62..2bf5fe998e 100644 --- a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts +++ b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts @@ -49,7 +49,7 @@ function subscribeSocketLifecycle(socket: Socket, socketIOData: WebsocketConnect ReturnType | ReturnType >(emit => { socket.on('connect', async () => { - console.log('websocket connected') + console.log('websocket connected!') emit(initActions.setWebsocketConnected(socketIOData)) }) socket.on('disconnect', () => { From 2f4e117ea4513970c064dd0c753d803af7b79448 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 12:17:50 +0100 Subject: [PATCH 5/7] Revert "chore: trigger mobile workflows" This reverts commit 0b150288350575d13c41eb489bc3717f0add4037. --- .../src/store/init/startConnection/startConnection.saga.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts index 2bf5fe998e..7911de1d62 100644 --- a/packages/mobile/src/store/init/startConnection/startConnection.saga.ts +++ b/packages/mobile/src/store/init/startConnection/startConnection.saga.ts @@ -49,7 +49,7 @@ function subscribeSocketLifecycle(socket: Socket, socketIOData: WebsocketConnect ReturnType | ReturnType >(emit => { socket.on('connect', async () => { - console.log('websocket connected!') + console.log('websocket connected') emit(initActions.setWebsocketConnected(socketIOData)) }) socket.on('disconnect', () => { From ced43ddb4e335ea1dbd39f5b3106719e0062abf0 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 16:28:58 +0100 Subject: [PATCH 6/7] fix: cleanup username creation component --- .../CreateUsername/CreateUsername.tsx | 18 ++--- .../CreateUsernameComponent.tsx | 78 ++++++++----------- .../UsernameTakenModal.container.tsx | 26 ++++++- .../src/sagas/errors/errors.selectors.ts | 7 +- .../src/sagas/users/users.selectors.ts | 9 ++- 5 files changed, 65 insertions(+), 73 deletions(-) diff --git a/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx b/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx index 2e0e904b3b..4844264b5a 100644 --- a/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx +++ b/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { ErrorCodes, LoadingPanelType } from '@quiet/types' -import { communities, errors, identity, network } from '@quiet/state-manager' +import { LoadingPanelType } from '@quiet/types' +import { communities, identity, network } from '@quiet/state-manager' import CreateUsernameComponent from '../CreateUsername/CreateUsernameComponent' import { ModalName } from '../../sagas/modals/modals.types' import { useModal } from '../../containers/hooks' @@ -15,8 +15,6 @@ const CreateUsername = () => { const createUsernameModal = useModal(ModalName.createUsernameModal) const loadingPanelModal = useModal(ModalName.loadingPanel) - const error = useSelector(errors.selectors.registrarErrors) - useEffect(() => { if (currentCommunity && !currentIdentity?.userCsr && !createUsernameModal.open) { createUsernameModal.handleOpen() @@ -26,17 +24,13 @@ const CreateUsername = () => { } }, [currentIdentity, currentCommunity]) - const handleAction = (nickname: string) => { - // Clear errors - if (error) { - dispatch(errors.actions.clearError(error)) - } - + const registerUsername = (nickname: string) => { dispatch( identity.actions.registerUsername({ nickname, }) ) + dispatch(network.actions.setLoadingPanelType(LoadingPanelType.Joining)) loadingPanelModal.handleOpen() } @@ -44,9 +38,7 @@ const CreateUsername = () => { return ( ) } diff --git a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx index b8d9e64e94..6286568774 100644 --- a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx +++ b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useCallback, useState } from 'react' import { styled } from '@mui/material/styles' import classNames from 'classnames' import { Controller, useForm } from 'react-hook-form' @@ -10,7 +10,6 @@ import { LoadingButton } from '../ui/LoadingButton/LoadingButton' import { TextInput } from '../../forms/components/textInput' import { userNameField } from '../../forms/fields/createUserFields' import { parseName } from '@quiet/common' -import { UserData } from '@quiet/types' const PREFIX = 'CreateUsernameComponent-' @@ -146,75 +145,67 @@ export enum UsernameVariant { export interface CreateUsernameComponentProps { open: boolean - registerUsername: (name: string) => void - certificateRegistrationError?: string - certificate?: string | null - handleClose: () => void - registeredUsers?: Record currentUsername?: string + registerUsername: (name: string) => void + registrationError?: string | null variant?: UsernameVariant + handleClose: () => void } export const CreateUsernameComponent: React.FC = ({ open, - registerUsername, - certificateRegistrationError, - certificate, - handleClose, currentUsername, - registeredUsers, + registerUsername, + registrationError, variant = UsernameVariant.NEW, + handleClose, }) => { const isNewUser = variant === UsernameVariant.NEW - const [isUsernameRequested, setIsUsernameRequested] = useState(false) const [formSent, setFormSent] = useState(false) + const [userName, setUserName] = useState('') const [parsedNameDiffers, setParsedNameDiffers] = useState(false) - const responseReceived = Boolean(certificateRegistrationError || certificate) - const waitingForResponse = formSent && !responseReceived + React.useEffect(() => { + if (registrationError) { + setError('userName', { message: registrationError }, { shouldFocus: true }) + } + }, [registrationError]) const { handleSubmit, formState: { errors }, setValue, setError, - control, clearErrors, + control, } = useForm({ mode: 'onTouched', }) - const onSubmit = (values: CreateUserValues) => { - if (isNewUser) { - submitForm(registerUsername, values, setFormSent) - } else { - registerUsername(parseName(values.userName)) - setIsUsernameRequested(true) + const onSubmit = useCallback((values: CreateUserValues) => { + if (Boolean(errors.userName)) { + console.error('Cannot submit form with errors') + return } - } - const submitForm = ( - handleSubmit: (value: string) => void, - values: CreateUserValues, - setFormSent: (value: boolean) => void - ) => { - setFormSent(true) - handleSubmit(parseName(values.userName)) - } + const parsedName = parseName(values.userName) + registerUsername(parsedName) + + if (variant === UsernameVariant.TAKEN) { + // It switches to post-sent view (only for taken variant) + setFormSent(true) + } + }, []) const onChange = (name: string) => { clearErrors('userName') + const parsedName = parseName(name) setUserName(parsedName) + setParsedNameDiffers(name !== parsedName) - if (registeredUsers && !isNewUser) { - const allUsersSet = new Set(Object.values(registeredUsers).map(user => user.username)) - if (allUsersSet.has(name)) { - setError('userName', { message: `${name} is already taken` }) - } - } } React.useEffect(() => { @@ -224,12 +215,6 @@ export const CreateUsernameComponent: React.FC = ( } }, [open]) - React.useEffect(() => { - if (certificateRegistrationError) { - setError('userName', { message: certificateRegistrationError }) - } - }, [certificateRegistrationError]) - return ( = ( isCloseDisabled={isNewUser} isBold={!isNewUser} addBorder={!isNewUser} - title={isNewUser ? undefined : isUsernameRequested ? 'New username requested' : 'Username taken'} + title={isNewUser ? undefined : formSent ? 'New username requested' : 'Username taken'} > - {!isUsernameRequested ? ( + {!formSent ? ( <>
@@ -325,8 +310,7 @@ export const CreateUsernameComponent: React.FC = ( { const dispatch = useDispatch() + const [registrationError, setRegistrationError] = React.useState(null) + const isUsernameTaken = useSelector(identity.selectors.usernameTaken) const usernameTakenModal = useModal(ModalName.usernameTakenModal) - const registeredUsers = useSelector(users.selectors.certificatesMapping) + + const registeredUsernames = useSelector(users.selectors.registeredUsernames) + const user = useSelector(identity.selectors.currentIdentity) const registerUsername = useCallback( (nickname: string) => { + // Reset registration error + setRegistrationError(null) + + // Trying to register the same username + if (nickname === user?.nickname) { + setRegistrationError('You cannot register with this username.') + return + } + + // Trying to register another already taken username + if (registeredUsernames.has(nickname)) { + setRegistrationError(`${nickname} is already taken`) + } + dispatch( identity.actions.registerUsername({ nickname, @@ -22,7 +40,7 @@ const UsernameTakenModalContainer = () => { }) ) }, - [dispatch] + [dispatch, user, registeredUsernames, setRegistrationError] ) useEffect(() => { @@ -37,8 +55,8 @@ const UsernameTakenModalContainer = () => { ) diff --git a/packages/state-manager/src/sagas/errors/errors.selectors.ts b/packages/state-manager/src/sagas/errors/errors.selectors.ts index 9abe91fb31..21fb217de9 100644 --- a/packages/state-manager/src/sagas/errors/errors.selectors.ts +++ b/packages/state-manager/src/sagas/errors/errors.selectors.ts @@ -3,7 +3,7 @@ import { currentCommunityId } from '../communities/communities.selectors' import { StoreKeys } from '../store.keys' import { type CreatedSelectors, type StoreState } from '../store.types' import { errorsAdapter } from './errors.adapter' -import { type ErrorPayload, SocketActionTypes } from '@quiet/types' +import { type ErrorPayload } from '@quiet/types' const errorSlice: CreatedSelectors[StoreKeys.Errors] = (state: StoreState) => state[StoreKeys.Errors] @@ -31,12 +31,7 @@ export const currentCommunityErrors = createSelector(currentCommunityId, selectA }, {}) }) -export const registrarErrors = createSelector(currentCommunityErrors, errors => { - return errors[SocketActionTypes.REGISTRAR] -}) - export const errorsSelectors = { generalErrors, currentCommunityErrors, - registrarErrors, } diff --git a/packages/state-manager/src/sagas/users/users.selectors.ts b/packages/state-manager/src/sagas/users/users.selectors.ts index 27ea53883c..be22dd748c 100644 --- a/packages/state-manager/src/sagas/users/users.selectors.ts +++ b/packages/state-manager/src/sagas/users/users.selectors.ts @@ -76,6 +76,8 @@ export const csrsMapping = createSelector(csrs, csrs => { return mapping }) +export const registeredUsernames = createSelector(certificatesMapping, mapping => new Set(Object.values(mapping).map(u => u.username))) + export const allUsers = createSelector(csrsMapping, certificatesMapping, (csrs, certs) => { const users: Record = {} @@ -149,13 +151,14 @@ export const areCertificatesLoaded = createSelector( ) export const usersSelectors = { - csrs, certificates, + csrs, certificatesMapping, csrsMapping, - ownerData, + registeredUsernames, allUsers, - duplicateCerts, getUserByPubKey, + ownerData, + duplicateCerts, areCertificatesLoaded, } From 433c5f92818d370d051da4adc1ad692a20ddbb35 Mon Sep 17 00:00:00 2001 From: siepra Date: Fri, 12 Jan 2024 16:33:21 +0100 Subject: [PATCH 7/7] Revert "fix: cleanup username creation component" This reverts commit ced43ddb4e335ea1dbd39f5b3106719e0062abf0. --- .../CreateUsername/CreateUsername.tsx | 18 +++-- .../CreateUsernameComponent.tsx | 78 +++++++++++-------- .../UsernameTakenModal.container.tsx | 26 +------ .../src/sagas/errors/errors.selectors.ts | 7 +- .../src/sagas/users/users.selectors.ts | 9 +-- 5 files changed, 73 insertions(+), 65 deletions(-) diff --git a/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx b/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx index 4844264b5a..2e0e904b3b 100644 --- a/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx +++ b/packages/desktop/src/renderer/components/CreateUsername/CreateUsername.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { LoadingPanelType } from '@quiet/types' -import { communities, identity, network } from '@quiet/state-manager' +import { ErrorCodes, LoadingPanelType } from '@quiet/types' +import { communities, errors, identity, network } from '@quiet/state-manager' import CreateUsernameComponent from '../CreateUsername/CreateUsernameComponent' import { ModalName } from '../../sagas/modals/modals.types' import { useModal } from '../../containers/hooks' @@ -15,6 +15,8 @@ const CreateUsername = () => { const createUsernameModal = useModal(ModalName.createUsernameModal) const loadingPanelModal = useModal(ModalName.loadingPanel) + const error = useSelector(errors.selectors.registrarErrors) + useEffect(() => { if (currentCommunity && !currentIdentity?.userCsr && !createUsernameModal.open) { createUsernameModal.handleOpen() @@ -24,13 +26,17 @@ const CreateUsername = () => { } }, [currentIdentity, currentCommunity]) - const registerUsername = (nickname: string) => { + const handleAction = (nickname: string) => { + // Clear errors + if (error) { + dispatch(errors.actions.clearError(error)) + } + dispatch( identity.actions.registerUsername({ nickname, }) ) - dispatch(network.actions.setLoadingPanelType(LoadingPanelType.Joining)) loadingPanelModal.handleOpen() } @@ -38,7 +44,9 @@ const CreateUsername = () => { return ( ) } diff --git a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx index 6286568774..b8d9e64e94 100644 --- a/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx +++ b/packages/desktop/src/renderer/components/CreateUsername/CreateUsernameComponent.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from 'react' +import React, { useState } from 'react' import { styled } from '@mui/material/styles' import classNames from 'classnames' import { Controller, useForm } from 'react-hook-form' @@ -10,6 +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 { UserData } from '@quiet/types' const PREFIX = 'CreateUsernameComponent-' @@ -145,67 +146,75 @@ export enum UsernameVariant { export interface CreateUsernameComponentProps { open: boolean - currentUsername?: string registerUsername: (name: string) => void - registrationError?: string | null - variant?: UsernameVariant + certificateRegistrationError?: string + certificate?: string | null handleClose: () => void + registeredUsers?: Record + currentUsername?: string + variant?: UsernameVariant } export const CreateUsernameComponent: React.FC = ({ open, - currentUsername, registerUsername, - registrationError, - variant = UsernameVariant.NEW, + certificateRegistrationError, + certificate, handleClose, + currentUsername, + registeredUsers, + variant = UsernameVariant.NEW, }) => { const isNewUser = variant === UsernameVariant.NEW + const [isUsernameRequested, setIsUsernameRequested] = useState(false) const [formSent, setFormSent] = useState(false) - const [userName, setUserName] = useState('') const [parsedNameDiffers, setParsedNameDiffers] = useState(false) - React.useEffect(() => { - if (registrationError) { - setError('userName', { message: registrationError }, { shouldFocus: true }) - } - }, [registrationError]) + const responseReceived = Boolean(certificateRegistrationError || certificate) + const waitingForResponse = formSent && !responseReceived const { handleSubmit, formState: { errors }, setValue, setError, - clearErrors, control, + clearErrors, } = useForm({ mode: 'onTouched', }) - const onSubmit = useCallback((values: CreateUserValues) => { - if (Boolean(errors.userName)) { - console.error('Cannot submit form with errors') - return + const onSubmit = (values: CreateUserValues) => { + if (isNewUser) { + submitForm(registerUsername, values, setFormSent) + } else { + registerUsername(parseName(values.userName)) + setIsUsernameRequested(true) } + } - const parsedName = parseName(values.userName) - registerUsername(parsedName) - - if (variant === UsernameVariant.TAKEN) { - // It switches to post-sent view (only for taken variant) - setFormSent(true) - } - }, []) + const submitForm = ( + handleSubmit: (value: string) => void, + values: CreateUserValues, + setFormSent: (value: boolean) => void + ) => { + setFormSent(true) + handleSubmit(parseName(values.userName)) + } const onChange = (name: string) => { clearErrors('userName') - const parsedName = parseName(name) setUserName(parsedName) - setParsedNameDiffers(name !== parsedName) + if (registeredUsers && !isNewUser) { + const allUsersSet = new Set(Object.values(registeredUsers).map(user => user.username)) + if (allUsersSet.has(name)) { + setError('userName', { message: `${name} is already taken` }) + } + } } React.useEffect(() => { @@ -215,6 +224,12 @@ export const CreateUsernameComponent: React.FC = ( } }, [open]) + React.useEffect(() => { + if (certificateRegistrationError) { + setError('userName', { message: certificateRegistrationError }) + } + }, [certificateRegistrationError]) + return ( = ( isCloseDisabled={isNewUser} isBold={!isNewUser} addBorder={!isNewUser} - title={isNewUser ? undefined : formSent ? 'New username requested' : 'Username taken'} + title={isNewUser ? undefined : isUsernameRequested ? 'New username requested' : 'Username taken'} > - {!formSent ? ( + {!isUsernameRequested ? ( <> @@ -310,7 +325,8 @@ export const CreateUsernameComponent: React.FC = ( { const dispatch = useDispatch() - const [registrationError, setRegistrationError] = React.useState(null) - const isUsernameTaken = useSelector(identity.selectors.usernameTaken) const usernameTakenModal = useModal(ModalName.usernameTakenModal) - - const registeredUsernames = useSelector(users.selectors.registeredUsernames) - + const registeredUsers = useSelector(users.selectors.certificatesMapping) const user = useSelector(identity.selectors.currentIdentity) const registerUsername = useCallback( (nickname: string) => { - // Reset registration error - setRegistrationError(null) - - // Trying to register the same username - if (nickname === user?.nickname) { - setRegistrationError('You cannot register with this username.') - return - } - - // Trying to register another already taken username - if (registeredUsernames.has(nickname)) { - setRegistrationError(`${nickname} is already taken`) - } - dispatch( identity.actions.registerUsername({ nickname, @@ -40,7 +22,7 @@ const UsernameTakenModalContainer = () => { }) ) }, - [dispatch, user, registeredUsernames, setRegistrationError] + [dispatch] ) useEffect(() => { @@ -55,8 +37,8 @@ const UsernameTakenModalContainer = () => { ) diff --git a/packages/state-manager/src/sagas/errors/errors.selectors.ts b/packages/state-manager/src/sagas/errors/errors.selectors.ts index 21fb217de9..9abe91fb31 100644 --- a/packages/state-manager/src/sagas/errors/errors.selectors.ts +++ b/packages/state-manager/src/sagas/errors/errors.selectors.ts @@ -3,7 +3,7 @@ import { currentCommunityId } from '../communities/communities.selectors' import { StoreKeys } from '../store.keys' import { type CreatedSelectors, type StoreState } from '../store.types' import { errorsAdapter } from './errors.adapter' -import { type ErrorPayload } from '@quiet/types' +import { type ErrorPayload, SocketActionTypes } from '@quiet/types' const errorSlice: CreatedSelectors[StoreKeys.Errors] = (state: StoreState) => state[StoreKeys.Errors] @@ -31,7 +31,12 @@ export const currentCommunityErrors = createSelector(currentCommunityId, selectA }, {}) }) +export const registrarErrors = createSelector(currentCommunityErrors, errors => { + return errors[SocketActionTypes.REGISTRAR] +}) + export const errorsSelectors = { generalErrors, currentCommunityErrors, + registrarErrors, } diff --git a/packages/state-manager/src/sagas/users/users.selectors.ts b/packages/state-manager/src/sagas/users/users.selectors.ts index be22dd748c..27ea53883c 100644 --- a/packages/state-manager/src/sagas/users/users.selectors.ts +++ b/packages/state-manager/src/sagas/users/users.selectors.ts @@ -76,8 +76,6 @@ export const csrsMapping = createSelector(csrs, csrs => { return mapping }) -export const registeredUsernames = createSelector(certificatesMapping, mapping => new Set(Object.values(mapping).map(u => u.username))) - export const allUsers = createSelector(csrsMapping, certificatesMapping, (csrs, certs) => { const users: Record = {} @@ -151,14 +149,13 @@ export const areCertificatesLoaded = createSelector( ) export const usersSelectors = { - certificates, csrs, + certificates, certificatesMapping, csrsMapping, - registeredUsernames, - allUsers, - getUserByPubKey, ownerData, + allUsers, duplicateCerts, + getUserByPubKey, areCertificatesLoaded, }