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
Unknown Object (File)
Thu, Apr 18, 2:21 AM
Unknown Object (File)
Thu, Apr 18, 2:21 AM
Unknown Object (File)
Thu, Apr 18, 2:21 AM
Unknown Object (File)
Thu, Apr 18, 2:17 AM
Unknown Object (File)
Mar 5 2024, 9:29 PM
Unknown Object (File)
Mar 5 2024, 9:29 PM
Unknown Object (File)
Mar 5 2024, 9:29 PM
Unknown Object (File)
Mar 5 2024, 9:29 PM
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/account/registration/avatar-selection.react.js
34–38 ↗(On Diff #27569)

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 ↗(On Diff #27569)

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 ↗(On Diff #27569)

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 ↗(On Diff #27569)

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