From 31a3016905ce4f6e2b035303e943e1ac2f8f0ccd Mon Sep 17 00:00:00 2001 From: Lucas Leblow Date: Mon, 15 Apr 2024 13:35:48 -0700 Subject: [PATCH] fix: Wait for community data in registerUsernameSaga (#2444) --- .../identity/registerUsername/registerUsername.saga.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.ts b/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.ts index 4622539f7f..ae91990777 100644 --- a/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.ts +++ b/packages/state-manager/src/sagas/identity/registerUsername/registerUsername.saga.ts @@ -5,6 +5,7 @@ import { identitySelectors } from '../identity.selectors' import { identityActions } from '../identity.slice' import { config } from '../../users/const/certFieldTypes' import { Socket } from '../../../types' +import { communitiesActions } from '../../communities/communities.slice' import { communitiesSelectors } from '../../communities/communities.selectors' import { CreateUserCsrPayload, RegisterCertificatePayload, Community } from '@quiet/types' @@ -16,7 +17,13 @@ export function* registerUsernameSaga( const { nickname, isUsernameTaken = false } = action.payload - const community = yield* select(communitiesSelectors.currentCommunity) + let community = yield* select(communitiesSelectors.currentCommunity) + + if (!community) { + yield* take(communitiesActions.addNewCommunity) + } + + community = yield* select(communitiesSelectors.currentCommunity) if (!community) { console.error('Could not register username, no community data')