Skip repeat editor capability fetches in MySiteViewModel#22833
Open
Skip repeat editor capability fetches in MySiteViewModel#22833
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
e1d374a to
17973a8
Compare
This was referenced May 4, 2026
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.
17973a8 to
5d99212
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 thelaunchinrefresh(), 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 whenfetchEditorCapabilitiesWithSnackbaris 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:onResume()calls → 1 fetchonResume()+ non-PTRrefresh()→ 1 fetchonResume()+ PTRrefresh(true)→ 2 fetchesrefresh(true)+onResume()→ 1 fetchManual verification:
apiRootorthemes?status=activerequests fire in logcat on the return.site.id).Related issues
Follow-up to #22785 — addresses one of the two follow-ups agreed in review.