Skip to content

Skip repeat editor capability fetches in MySiteViewModel#22833

Open
jkmassel wants to merge 1 commit intotrunkfrom
jkmassel/pr-22785-followups
Open

Skip repeat editor capability fetches in MySiteViewModel#22833
jkmassel wants to merge 1 commit intotrunkfrom
jkmassel/pr-22785-followups

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel commented May 4, 2026

Description

Follow-up to #22785 (review feedback from @nbradbury). The capability fetch in MySiteViewModel.onResume() (apiRoot + themes?status=active) was firing on every return to the My Site tab — combined with the launch in refresh(), the same two requests could fire twice in close succession (e.g. resume after pull-to-refresh).

Editor capabilities rarely change, so we now dedup with an in-memory set keyed by site.id, populated when fetchEditorCapabilitiesWithSnackbar is first attempted for a site this ViewModel session. Subsequent non-user-initiated calls return early. User-initiated paths (pull-to-refresh, refresh(isPullToRefresh = true)) bypass the gate so the user can always force a fresh fetch.

Per-session caching is sufficient — no TTL or persistent storage needed. The next ViewModel session will refetch.

Testing instructions

Covered by four new unit tests in MySiteViewModelTest:

  • Two onResume() calls → 1 fetch
  • onResume() + non-PTR refresh() → 1 fetch
  • onResume() + PTR refresh(true) → 2 fetches
  • PTR refresh(true) + onResume() → 1 fetch

Manual verification:

  1. Open the app and navigate to the My Site tab on a site with cached capabilities.
  2. Navigate away to another tab and back to My Site.
  • Verify no apiRoot or themes?status=active requests fire in logcat on the return.
  1. Pull-to-refresh the My Site tab.
  • Verify both requests fire on the PTR.
  1. Switch the selected site, then return to My Site.
  • Verify capabilities are fetched for the newly-selected site (different site.id).

Related issues

Follow-up to #22785 — addresses one of the two follow-ups agreed in review.

@dangermattic
Copy link
Copy Markdown
Collaborator

dangermattic commented May 4, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 4, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22833-5d99212
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit5d99212
Installation URL4vpvnol0jirog
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 4, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22833-5d99212
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit5d99212
Installation URL2h7ml192tejv8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 4, 2026

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Follow-up to #22785: the capability fetch (apiRoot + themes?status=active)
was firing on every onResume of the My Site tab. Dedup with an in-memory
set keyed by site.id so it only runs once per ViewModel session.
Pull-to-refresh bypasses the gate so users can still force a fresh fetch.
@jkmassel jkmassel force-pushed the jkmassel/pr-22785-followups branch from 17973a8 to 5d99212 Compare May 4, 2026 19:54
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.21%. Comparing base (57acb95) to head (5d99212).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22833   +/-   ##
=======================================
  Coverage   37.20%   37.21%           
=======================================
  Files        2317     2317           
  Lines      124509   124513    +4     
  Branches    16907    16909    +2     
=======================================
+ Hits        46324    46336   +12     
+ Misses      74438    74432    -6     
+ Partials     3747     3745    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jkmassel jkmassel requested a review from nbradbury May 4, 2026 20:22
@jkmassel jkmassel self-assigned this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Editing and display of Gutenberg blocks. /My site Performance [Type] Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants