Skip to content

Seed the Likes screen from cache when opening it from Post Stats - #25878

Draft
crazytonyli wants to merge 6 commits into
trunkfrom
cmm-2218-post-stats-likes-cache-bridge
Draft

Seed the Likes screen from cache when opening it from Post Stats#25878
crazytonyli wants to merge 6 commits into
trunkfrom
cmm-2218-post-stats-likes-cache-bridge

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

Note

I recommend reviewing this PR commit by commit. The first commit is a swift-format-only reflow of the touched files (no behavior change), separated out so the functional commits stay readable.

Description

Fixes https://linear.app/a8c/issue/CMM-2218

The Post Stats screen fetches a post's likers for its avatar strip but keeps them only in SwiftUI state. The Likes screen it navigates to reads the shared LikeUser Core Data cache first, but nothing Post Stats fetched ever enters that cache, so a first visit starts empty and refetches the same endpoint.

  1. Post Stats now writes the likers it fetches into the shared LikeUser cache, so the Likes list seeds itself instantly instead of starting empty. JetpackStats can't depend on Core Data, so it exposes a store-only PostLikesStore port (with a PostLikeSeed value type) and the app injects a StatsPostLikesStore adapter backed by a new LikeUserHelper.upsert that merges rows without purging. The Likes screen itself is unchanged; its existing cache-first read picks up the seeds.
  2. Pre-existing bug fix: a successful empty first-page likes response now purges the post's cached rows in PostService.getLikesFor, so the list can't show a stale liker under a "0 likes" title. The seed path relies on the same behavior: a confirmed totalCount == 0 from Post Stats clears the post's cache (and that clear is awaited before the zero total is exposed, so a fast tap-through can't snapshot stale rows).

One thing to look at: deleteExistingUsersFor now uses a plain predicate when nothing is kept, because Core Data's SQLite store does not reliably evaluate NOT (self IN <empty array>).

Testing instructions

  • On a site with a liked post, open the post's Stats (post list -> more menu -> Stats), wait for the likes strip, then tap through to the Likes list. It should render the likers immediately with @username subtitles, no empty state.
  • Regression on the shared Likes screen (posts and comments): a post with likes still lists correctly, and reaching the last (empty) page of a multi-page list does not wipe the cache.

@dangermattic

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@crazytonyli crazytonyli changed the title Cmm 2218 post stats likes cache bridge Seed the Likes screen from cache when opening it from Post Stats Aug 7, 2026
@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number33651
VersionPR #25878
Bundle IDorg.wordpress.alpha
Commitc7d53ac
Installation URL5t1dsun3minb8
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
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33651
VersionPR #25878
Bundle IDcom.jetpack.alpha
Commitc7d53ac
Installation URL1kaqlars9hcjg
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

🤖 Build Failure Analysis

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants