From b9e83de065cd2ecf7ba1fb28e31ceae748703cbe Mon Sep 17 00:00:00 2001 From: Nikolaus Heger Date: Wed, 27 Oct 2021 10:10:18 +0800 Subject: [PATCH] hotfix: set user name in createUserNameState on validation (#1293) This allows users to enter a custom username --- .../create_username/mappers/create_username_mapper.dart | 7 +++++-- .../create_username/usecases/create_username_usecase.dart | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/screens/authentication/sign_up/create_username/mappers/create_username_mapper.dart b/lib/screens/authentication/sign_up/create_username/mappers/create_username_mapper.dart index 52f6a529b..979e3fc57 100644 --- a/lib/screens/authentication/sign_up/create_username/mappers/create_username_mapper.dart +++ b/lib/screens/authentication/sign_up/create_username/mappers/create_username_mapper.dart @@ -5,12 +5,15 @@ import 'package:seeds/screens/authentication/sign_up/viewmodels/bloc.dart'; import 'package:seeds/screens/authentication/sign_up/viewmodels/states/create_username_state.dart'; class CreateUsernameMapper extends StateMapper { - SignupState mapValidateUsernameToState(SignupState currentState, Result result) { + SignupState mapValidateUsernameToState(SignupState currentState, String username, Result result) { final createUsernameCurrentState = currentState.createUsernameState; if (result.isError) { // Error means username is not taken and is available for the user to take it - final newState = createUsernameCurrentState.copyWith(pageState: PageState.success); + final newState = createUsernameCurrentState.copyWith( + username: username, + pageState: PageState.success, + ); return currentState.copyWith(createUsernameState: newState); } diff --git a/lib/screens/authentication/sign_up/create_username/usecases/create_username_usecase.dart b/lib/screens/authentication/sign_up/create_username/usecases/create_username_usecase.dart index e7e03c4d2..21fe34282 100644 --- a/lib/screens/authentication/sign_up/create_username/usecases/create_username_usecase.dart +++ b/lib/screens/authentication/sign_up/create_username/usecases/create_username_usecase.dart @@ -18,7 +18,7 @@ class CreateUsernameUseCase { final Result result = await _signupRepository.isUsernameTaken(username); - yield CreateUsernameMapper().mapValidateUsernameToState(currentState, result); + yield CreateUsernameMapper().mapValidateUsernameToState(currentState, username, result); } else { yield currentState.copyWith( createUsernameState: CreateUsernameState.error(currentState.createUsernameState, validationError));