Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Session] Call persist handler directly #3828

Merged
merged 1 commit into from
May 2, 2024
Merged

[Session] Call persist handler directly #3828

merged 1 commit into from
May 2, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented May 2, 2024

Extracted from #3728.

This is a plain refactor, no change in functionality. We had a bunch of indirection that turned out to be unnecessary and that made it way harder to read what this code is actually doing. This removes the indirection.

Concretely, networkErrorCallback was always specified to be clearCurrentAccount, and persistSessionCallback was always specified to be upsertAccount. So this inlines those calls directly and removes the configurable parameters.

There are likely some fixes and simplifications we can do on top but let's get this in first.

Test Plan

This is a bit tricky to test because you need to trigger one of the conditions that get us into the persist handler. One of those is the initial update when resuming a session. So what I've done is:

  • Disabled the localStorage persistence writing code
  • Updated 2FA setting in another tab
  • Refreshed current tab
  • Observed that we start out with stale account info, and then the new one gets applied via this callback

You can also just read the code with whitespace off and verify it's a mechanical transformation.

Copy link

render bot commented May 2, 2024

Copy link

github-actions bot commented May 2, 2024

Old size New size Diff
6.85 MB 6.85 MB -336 B (-0.00%)

@gaearon gaearon merged commit 6405ad7 into main May 2, 2024
6 checks passed
@gaearon gaearon deleted the session-pt-5 branch May 2, 2024 22:05
@gaearon gaearon mentioned this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants