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

fix: Unnecessary Account Tracker state update #4837

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tommasini
Copy link
Contributor

@tommasini tommasini commented Oct 22, 2024

Explanation

Unnecessary state update when the balance did not change at account tracker controller polling mechanism, which was causing unnecessary re renders

References

Changelog

@metamask/assets-controllers

  • : Only updated the state if the balance changes
  • : Your change here

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

…racker controller polling mechanism, which was causing unnecessary re renders
@tommasini tommasini added needs-dev-review team-tiger Tiger team (for tech debt reduction + performance improvements) labels Oct 22, 2024
Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Let's add a unit test for this

github-merge-queue bot pushed a commit to MetaMask/metamask-mobile that referenced this pull request Oct 23, 2024
## **Description**

Activity view and every component that uses the selector
`selectAccountsByChainId` was re rendering when the state was [updating
with the same value
](https://github.com/MetaMask/core/blob/c970faff01eae893bc32ae7c7a513fbb31495182/packages/assets-controllers/src/AccountTrackerController.ts#L327).

We should aim to only update the state when there is changes. [Draft
created](MetaMask/core#4837)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**



https://github.com/user-attachments/assets/6871de37-09ee-4452-b2b1-79e0286c1e4c



### **After**

<!-- [screenshots/recordings] -->


https://github.com/user-attachments/assets/eeb62987-d2c0-40d8-aa33-0aefce309e50



## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review team-tiger Tiger team (for tech debt reduction + performance improvements)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants