You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## **Description**
This PR fixes a bug where the Authentication API was being called on
every re-render of `useCarouselManagement` because of infinite
`getUserProfileLineage` requests, creating scenarios where users were
being rate limited and couldn't authenticate.
[](https://codespaces.new/MetaMask/metamask-extension/pull/37334?quickstart=1)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Fixed a bug where the Authentication API was called
infinitely in useCarouselManagement
## **Related issues**
Fixes: #35367 ,
[MUL-1220](https://consensyssoftware.atlassian.net/browse/MUL-1220),
potentially
[MUL-1190](https://consensyssoftware.atlassian.net/browse/MUL-1190)
## **Manual testing steps**
1. Complete onboarding
2. Open the network tab, filter it by typing "lineage"
3. Switch accounts and verify the calls are only happening here
4. Verify that there are no infinite calls to the Authentication API
anymore
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Separates download eligibility into its own effect to avoid repeated
lineage calls, gates Contentful fetch until ready, and adds a test
ensuring lineage runs once per account.
>
> - **Hook (`ui/hooks/useCarouselManagement/useCarouselManagement.ts`)**
> - Introduces `downloadEligible` and `downloadEligibilityReady` state
and a dedicated effect to compute eligibility via
`getUserProfileLineage`, with cancellation and error handling.
> - Gates Contentful slide fetching on `downloadEligibilityReady`; uses
`contentfulEnabled` derived flag and removes it from deps in favor of
the derived value.
> - Applies eligibility when including `downloadMobileApp` slides;
preserves existing behavior for `fund` slide and slide ordering.
> - Refines effect dependency arrays (e.g., replaces
`remoteFeatureFlags` with `contentfulEnabled`).
> - **Tests
(`ui/hooks/useCarouselManagement/useCarouselManagement.test.ts`)**
> - Adds test verifying lineage is called only once per account and not
on slide changes.
> - Updates mocks and helpers accordingly.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0898e82. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[MUL-1220]:
https://consensyssoftware.atlassian.net/browse/MUL-1220?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
0 commit comments