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

Replace getAgent() with reading agent #4243

Merged
merged 2 commits into from
May 28, 2024
Merged

Replace getAgent() with reading agent #4243

merged 2 commits into from
May 28, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented May 28, 2024

After the session refactor, we have a guarantee that the agent within the tree is always the same instance. Let's take advantage of that guarantee and make it clearer in the code by removing the getAgent indirection.

Before:

  const {getAgent} = useAgent()
  // usage
  getAgent().foo.bar()

After:

  const {agent} = useAgent()
  // usage
  agent.foo.bar()

## Test Plan

See session/index.tsx, notice that there's no actual change in semantics. The value was already being captured in a closure.

Then read through the code. Most of this is simple find-and-replace, with some manual edits to fix types. I relied on types to fix the rest.

Do some basic things in the app, switch accounts, verify that still works.

Copy link

render bot commented May 28, 2024

Copy link

Old size New size Diff
7.3 MB 7.3 MB -420 B (-0.01%)

Copy link
Contributor

@haileyok haileyok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd+f'd the codebase, don't see any other getAgent calls. Also clicked around a bit and didn't have any issues, seems good to me.

@gaearon gaearon merged commit 9bd411c into main May 28, 2024
6 checks passed
@gaearon gaearon deleted the rm-get-agent branch May 28, 2024 15:37
estrattonbailey added a commit that referenced this pull request May 28, 2024
* origin/main: (392 commits)
  Remove old onboarding (#4224)
  Replace getAgent() with reading agent (#4243)
  Bump 1.85.0 (#4237)
  bump iOS target to `14.0` (#4238)
  set `onEndReachedThreshold` to `2` for notifications (#4235)
  Run intl extract (#4217)
  Updated Japanese translation (#4144)
  Updated Chinese translation (#4147)
  Update Korean localization (#4148)
  Update catalan messages.po (#4149)
  Update Indonesian translation (#4165)
  [🐴] update convo list from message bus (#4189)
  Recover from initial failed firehose state (#4211)
  Move ALT indicator right and shrink it a bit (#4213)
  Make sure failed messages enter error state (#4210)
  [🐴] Don't submit the message on return press when on a phone (web input) (#4203)
  Include feedContext in DOM as data- (#4206)
  Improve moderation behaviors: show alert/inform sources and improve UX around threads (#3677)
  Privileged app passwords (#4200)
  [🐴] Overfetch follow for default new dialog state (#4205)
  ...
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