diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-07-02 14:43:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 22:43:34 +0100 |
commit | 63bb8fda2d28e11d7e60808e1e86384d48ec1b47 (patch) | |
tree | 077d366a888ceb4c0c925707e2d2989ad7bf7fdb /src/screens/Signup/state.ts | |
parent | 4bb4452f0858f2f5f8f6ead3012307cdf4b6a67f (diff) | |
download | voidsky-63bb8fda2d28e11d7e60808e1e86384d48ec1b47.tar.zst |
Improve textinput performance in login and account creation (#4673)
* Change login form to use uncontrolled inputs * Debounce state updates in account creation to reduce flicker * Refactor state-control of account creation forms to fix perf without relying on debounces * Remove canNext and enforce is13 * Re-add live validation to signup form (#4720) * Update validation in real time * Disable on invalid * Clear server error on typing * Remove unnecessary clearing of error --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/screens/Signup/state.ts')
-rw-r--r-- | src/screens/Signup/state.ts | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/screens/Signup/state.ts b/src/screens/Signup/state.ts index 87700cb88..826cbf1d3 100644 --- a/src/screens/Signup/state.ts +++ b/src/screens/Signup/state.ts @@ -10,7 +10,7 @@ import * as EmailValidator from 'email-validator' import {DEFAULT_SERVICE} from '#/lib/constants' import {cleanError} from '#/lib/strings/errors' -import {createFullHandle, validateHandle} from '#/lib/strings/handles' +import {createFullHandle} from '#/lib/strings/handles' import {getAge} from '#/lib/strings/time' import {logger} from '#/logger' import {useSessionApi} from '#/state/session' @@ -28,7 +28,6 @@ export enum SignupStep { export type SignupState = { hasPrev: boolean - canNext: boolean activeStep: SignupStep serviceUrl: string @@ -58,12 +57,10 @@ export type SignupAction = | {type: 'setHandle'; value: string} | {type: 'setVerificationCode'; value: string} | {type: 'setError'; value: string} - | {type: 'setCanNext'; value: boolean} | {type: 'setIsLoading'; value: boolean} export const initialState: SignupState = { hasPrev: false, - canNext: false, activeStep: SignupStep.INFO, serviceUrl: DEFAULT_SERVICE, @@ -144,10 +141,6 @@ export function reducer(s: SignupState, a: SignupAction): SignupState { next.handle = a.value break } - case 'setCanNext': { - next.canNext = a.value - break - } case 'setIsLoading': { next.isLoading = a.value break @@ -160,23 +153,6 @@ export function reducer(s: SignupState, a: SignupAction): SignupState { next.hasPrev = next.activeStep !== SignupStep.INFO - switch (next.activeStep) { - case SignupStep.INFO: { - const isValidEmail = EmailValidator.validate(next.email) - next.canNext = - !!(next.email && next.password && next.dateOfBirth) && - (!next.serviceDescription?.inviteCodeRequired || !!next.inviteCode) && - is13(next.dateOfBirth) && - isValidEmail - break - } - case SignupStep.HANDLE: { - next.canNext = - !!next.handle && validateHandle(next.handle, next.userDomain).overall - break - } - } - logger.debug('signup', next) if (s.activeStep !== next.activeStep) { |