Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3521317
D13311.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13311.diff
View Options
diff --git a/native/account/registration/username-selection.react.js b/native/account/registration/username-selection.react.js
--- a/native/account/registration/username-selection.react.js
+++ b/native/account/registration/username-selection.react.js
@@ -9,7 +9,6 @@
exactSearchUserActionTypes,
} from 'lib/actions/user-actions.js';
import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
-import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { validUsernameRegex } from 'lib/shared/account-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -28,13 +27,8 @@
type NavigationRoute,
PasswordSelectionRouteName,
} from '../../navigation/route-names.js';
-import { useSelector } from '../../redux/redux-utils.js';
import { useStyles } from '../../themes/colors.js';
-const exactSearchUserLoadingStatusSelector = createLoadingStatusSelector(
- exactSearchUserActionTypes,
-);
-
export type UsernameSelectionParams = {
+userSelections: {
+coolOrNerdMode?: ?CoolOrNerdMode,
@@ -80,6 +74,9 @@
return undefined;
}, [keyserverURL]);
+ const [usernameSearchLoading, setUsernameSearchLoading] =
+ React.useState(false);
+
const exactSearchUserCall = useLegacyAshoatKeyserverCall(
exactSearchUser,
serverCallParamOverride,
@@ -91,18 +88,24 @@
return;
}
+ setUsernameSearchLoading(true);
+
let userAlreadyExists;
- if (usingCommServicesAccessToken) {
- const findUserIDResponseString =
- await commRustModule.findUserIDForUsername(username);
- const findUserIDResponse = JSON.parse(findUserIDResponseString);
- userAlreadyExists =
- !!findUserIDResponse.userID || findUserIDResponse.isReserved;
- } else {
- const searchPromise = exactSearchUserCall(username);
- void dispatchActionPromise(exactSearchUserActionTypes, searchPromise);
- const { userInfo } = await searchPromise;
- userAlreadyExists = !!userInfo;
+ try {
+ if (usingCommServicesAccessToken) {
+ const findUserIDResponseString =
+ await commRustModule.findUserIDForUsername(username);
+ const findUserIDResponse = JSON.parse(findUserIDResponseString);
+ userAlreadyExists =
+ !!findUserIDResponse.userID || findUserIDResponse.isReserved;
+ } else {
+ const searchPromise = exactSearchUserCall(username);
+ void dispatchActionPromise(exactSearchUserActionTypes, searchPromise);
+ const { userInfo } = await searchPromise;
+ userAlreadyExists = !!userInfo;
+ }
+ } finally {
+ setUsernameSearchLoading(false);
}
if (userAlreadyExists) {
@@ -134,11 +137,8 @@
userSelections,
]);
- const exactSearchUserCallLoading = useSelector(
- state => exactSearchUserLoadingStatusSelector(state) === 'loading',
- );
let buttonVariant = 'disabled';
- if (exactSearchUserCallLoading) {
+ if (usernameSearchLoading) {
buttonVariant = 'loading';
} else if (validUsername) {
buttonVariant = 'enabled';
@@ -195,7 +195,7 @@
autoComplete="username-new"
returnKeyType="go"
onSubmitEditing={onProceed}
- editable={!exactSearchUserCallLoading}
+ editable={!usernameSearchLoading}
onBlur={checkUsernameValidity}
/>
<View style={styles.error}>{errorText}</View>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 2:55 AM (17 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2698074
Default Alt Text
D13311.diff (3 KB)
Attached To
Mode
D13311: [native] Fix UsernameSelection loading state when usingCommServicesAccessToken
Attached
Detach File
Event Timeline
Log In to Comment