Page MenuHomePhabricator

[native] Add cached user selection state into RegistrationContext
ClosedPublic

Authored by ashoat on Jun 8 2023, 1:18 PM.
Tags
None
Referenced Files
F3373828: D8154.diff
Tue, Nov 26, 12:04 PM
F3371319: D8154.diff
Tue, Nov 26, 4:37 AM
Unknown Object (File)
Fri, Nov 8, 12:29 AM
Unknown Object (File)
Thu, Nov 7, 11:00 AM
Unknown Object (File)
Thu, Nov 7, 11:00 AM
Unknown Object (File)
Thu, Nov 7, 11:00 AM
Unknown Object (File)
Thu, Nov 7, 11:00 AM
Unknown Object (File)
Fri, Nov 1, 7:26 AM
Subscribers

Details

Summary

This addresses ENG-4043. Basically we want to be able to preserve the state for a screen after going back and then navigating to the screen again. For instance, if the user has entered their password but wishes to revise their username, we want them to be able to go back without losing their already-typed-in password.

I initially tried replacing the React Navigation state with this new state, but then realized that since React Navigation state is persisted in dev mode, but RegistrationContext state is not, we could get in a place (only in dev mode) where data necessary for rendering the current screen is not available in RegistrationContext. As a result, this state is being introduced ONLY for "preseeding" initial state when screens are first rendered.

Depends on D8153

Test Plan

I tested going back for every screen after setting values (and proceeding). In some cases, a simple selection was enough to update cached state; in those cases, I also tested without "proceeding" (ie. pressing "Next")

Diff Detail

Repository
rCOMM Comm
Branch
ashoat/registration
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/account/registration/avatar-selection.react.js
34–38

I moved this to registration-types.js (and renamed to ensAvatarSelection) so it could be reused in ConnectEthereum. I can move this change into its own diff if helpful

42

I renamed this at some point for clarity. I can move this change into its own diff if helpful

native/account/registration/password-selection.react.js
165

We use a ref here so that shouldAutoFocus doesn't change after the first render, to avoid unnecessary rerenders of the effect below and RegistrationTextInput (autoFocus only matters on mount)

native/account/registration/username-selection.react.js
156

We use a ref here so that shouldAutoFocus doesn't change after the first render, to avoid unnecessary rerenders of RegistrationTextInput (autoFocus only matters on mount)

ashoat requested review of this revision.Jun 8 2023, 1:37 PM

Thanks for the annotations

This revision is now accepted and ready to land.Jun 9 2023, 12:36 PM