HomePhabricator
Diffusion Comm 7afb2d14a6a8

[lib] Use useDerivedObject to reduce renders due to preRequestUserState

Description

[lib] Use useDerivedObject to reduce renders due to preRequestUserState

Summary:
While working on ENG-7385, I did some investigation to see why performAuth was getting regenerated. It turned out that it was largely due to preRequestUserState being regenerated.

It's hard to properly memoize this, since we need to memoize N pieces of data for each entry in an object. Neither createSelector nor useMemo can handle an unbounded list of data.

I introduced useDerivedObject in D10465 to solve precisely this problem. By integrating it here (in addition to the preceding diff) I was able to solve the issue of performAuth being cancelled during initial keyserverAuth following new user registration.

Depends on D11655

Test Plan:

  1. I added logs for when the performAuth got cancelled and restarted
  2. I ran through the new registration flow
  3. I confirmed that when the registration button was pressed, I no longer saw any logs about performAuth getting cancelled and restarted, and that we were no longer wasting an unnecessary amount of one-time keys

Reviewers: inka

Reviewed By: inka

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D11656

Details

Provenance
ashoatAuthored on Apr 12 2024, 2:07 PM
Reviewer
inka
Differential Revision
D11656: [lib] Use useDerivedObject to reduce renders due to preRequestUserState
Parents
rCOMMfaa663cd9927: [lib] Introduce usePreRequestUserState
Branches
Unknown
Tags
Unknown