Skip to content

Commit 43de0fb

Browse files
authored
fix: activity list refetch cp-13.20.0 (#40340)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Update the refetch strategy of the Activity list and use the shared stale time constant Fixes the scroll jump issues and avoids unnecessary requests [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/40340?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: null ## **Related issues** Fixes: #40359 ## **Manual testing steps** 1. Go to Activity tab 2. Navigate away and back 3. Refetch should only happen after stale time has elapsed ## **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** - [ ] 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). - [ ] 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-extension/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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small React Query configuration change that only affects refresh timing for the Activity list; no auth, security, or data-shape changes. > > **Overview** > Activity list transaction fetching no longer forces periodic refresh: it removes `refetchInterval` and the explicit `refetchOnWindowFocus: false`, and uses the shared `STALE_TIMES.TRANSACTIONS` constant instead of a hard-coded 15s `staleTime`. > > This shifts when the list refetches to React Query’s default triggers and the centralized staleness configuration (while still allowing callers to override via `options`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 02219d3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 1a3c94a commit 43de0fb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ui/helpers/queries.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { UseInfiniteQueryOptions } from '@tanstack/react-query';
22
import type { V4MultiAccountTransactionsResponse } from '@metamask/core-backend';
3+
import { STALE_TIMES } from '@metamask/core-backend';
34
import type { NormalizedV4MultiAccountTransactionsResponse } from '../../shared/lib/multichain/types';
45
import { selectTransactions } from '../../shared/lib/multichain/transformations';
56
import { apiClient } from './api-client';
@@ -53,9 +54,7 @@ export const queries = {
5354
select: selectTransactions(evmAddress),
5455
getNextPageParam: ({ pageInfo }) =>
5556
pageInfo.hasNextPage ? pageInfo.endCursor : undefined,
56-
refetchOnWindowFocus: false,
57-
refetchInterval: 15 * 1000,
58-
staleTime: 15 * 1000,
57+
staleTime: STALE_TIMES.TRANSACTIONS,
5958
...options,
6059
enabled: Boolean(accountAddresses[0]) && (options?.enabled ?? true),
6160
};

0 commit comments

Comments
 (0)