diff --git a/src/logger/metrics.ts b/src/logger/metrics.ts index 46ce3c7cae..4b1ea5230b 100644 --- a/src/logger/metrics.ts +++ b/src/logger/metrics.ts @@ -70,6 +70,7 @@ export type MetricEvents = { 'signup:handleTaken': {typeahead?: boolean} 'signup:handleReserved': {typeahead?: boolean} 'signup:handleAvailable': {typeahead?: boolean} + 'signup:handleSuggestionSelected': {method: string} 'signin:hostingProviderPressed': { hostingProviderDidChange: boolean } diff --git a/src/screens/Signup/StepHandle.tsx b/src/screens/Signup/StepHandle.tsx index 980389450c..60a1b0083e 100644 --- a/src/screens/Signup/StepHandle.tsx +++ b/src/screens/Signup/StepHandle.tsx @@ -1,10 +1,10 @@ import {useState} from 'react' import {View} from 'react-native' import Animated, { + Easing, FadeIn, FadeInDown, FadeOut, - FadeOutDown, LayoutAnimationConfig, LinearTransition, } from 'react-native-reanimated' @@ -42,7 +42,10 @@ export function StepHandle() { const validCheck = validateServiceHandle(draftValue, state.userDomain) - const {data: isHandleAvailable, isLoading} = useHandleAvailabilityQuery({ + const { + enabled: queryEnabled, + query: {data: isHandleAvailable, isPending}, + } = useHandleAvailabilityQuery({ username: draftValue, serviceDid: state.serviceDescription?.did ?? 'UNKNOWN', serviceDomain: state.userDomain, @@ -121,7 +124,10 @@ export function StepHandle() { } const textFieldInvalid = - (!isLoading && isHandleAvailable && !isHandleAvailable.available) || + (!isPending && + queryEnabled && + isHandleAvailable && + !isHandleAvailable.available) || !validCheck.frontLengthNotTooLong || !validCheck.handleChars || !validCheck.hyphenStartOrEnd || @@ -129,7 +135,7 @@ export function StepHandle() { return ( - + @@ -142,7 +148,7 @@ export function StepHandle() { setDraftValue(val) }} label={state.userDomain} - defaultValue={draftValue} + value={draftValue} keyboardType="ascii-capable" // fix for iOS replacing -- with — autoCapitalize="none" autoCorrect={false} @@ -166,7 +172,8 @@ export function StepHandle() { {state.error} )} - {isHandleAvailable && + {queryEnabled && + isHandleAvailable && !isHandleAvailable.available && validCheck.overall && ( <> @@ -189,7 +196,9 @@ export function StepHandle() { state.userDomain.length * -1, ), ) - // TODO: add logging + logger.metric('signup:handleSuggestionSelected', { + method: suggestion.method, + }) }} /> )} @@ -225,12 +234,14 @@ export function StepHandle() { - + + + ) } @@ -270,33 +281,43 @@ function HandleSuggestions({ return ( {suggestions.map((suggestion, index) => (