Skip to content

Add the discovery data layer behind Daily Picks, Trending and Recently Viewed - #114

Open
AndrewG828 wants to merge 1 commit into
user/andrewgao/feature/UI-UX-Lucid-Refactor-03-listing-cardsfrom
user/andrewgao/feature/UI-UX-Lucid-Refactor-04-discovery-data-layer
Open

Add the discovery data layer behind Daily Picks, Trending and Recently Viewed#114
AndrewG828 wants to merge 1 commit into
user/andrewgao/feature/UI-UX-Lucid-Refactor-03-listing-cardsfrom
user/andrewgao/feature/UI-UX-Lucid-Refactor-04-discovery-data-layer

Conversation

@AndrewG828

@AndrewG828 AndrewG828 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Stacked PR 4 of 15. Based on #113 — merge in order.
#111#112#113#114#115#116#117#118#119#120#121#122#123#124#125

Three new endpoints and the two view models that drive the Explore tab. No UI
consumes them yet apart from view recording.

NetworkManager gains getDailyPicks, getTrendingPosts(category:page:limit:)
and recordPostView. The last one needed a post(url:) overload because it is
the first request in the app that sends no body and decodes no response — the
server upserts one view per viewer/post/UTC-day and ignores your own listings,
so the client can fire it unconditionally and ignore failures.

ExploreViewModel is a shared singleton with a 3-minute freshness window, since
Explore is a tab root that re-appears constantly and should not refetch on every
visit. Trending is keyed by category so switching categories bypasses the cache.

RecentlyViewedViewModel keeps its own ordered id list plus a listing cache in
AppStorage, so the section renders from disk on launch and only fetches the
posts it is missing, eight at a time. ProductDetailsViewModel.setPost is what
feeds it — opening a listing caches it locally and reports the view to the
server.

Post picks up the save-count fields. The count arrives under three different
key spellings depending on endpoint, and getPostInfo returns savers as a
user array rather than a number, so displaySaveCount takes the largest of
whatever decoded. Trending payloads often omit savers entirely, hence
ensuringMinimumSaves — if the viewer has the post saved locally, the true
count is at least one. That is a lower bound, not a global total; worth
confirming against the backend before we lean on it further.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_017R8mua9xepzF3mnRETtd6W

…y Viewed

Three new endpoints and the two view models that drive the Explore tab. No UI
consumes them yet apart from view recording.

`NetworkManager` gains `getDailyPicks`, `getTrendingPosts(category:page:limit:)`
and `recordPostView`. The last one needed a `post(url:)` overload because it is
the first request in the app that sends no body and decodes no response — the
server upserts one view per viewer/post/UTC-day and ignores your own listings,
so the client can fire it unconditionally and ignore failures.

`ExploreViewModel` is a shared singleton with a 3-minute freshness window, since
Explore is a tab root that re-appears constantly and should not refetch on every
visit. Trending is keyed by category so switching categories bypasses the cache.

`RecentlyViewedViewModel` keeps its own ordered id list plus a listing cache in
`AppStorage`, so the section renders from disk on launch and only fetches the
posts it is missing, eight at a time. `ProductDetailsViewModel.setPost` is what
feeds it — opening a listing caches it locally and reports the view to the
server.

`Post` picks up the save-count fields. The count arrives under three different
key spellings depending on endpoint, and `getPostInfo` returns `savers` as a
user array rather than a number, so `displaySaveCount` takes the largest of
whatever decoded. Trending payloads often omit savers entirely, hence
`ensuringMinimumSaves` — if the viewer has the post saved locally, the true
count is at least one. That is a lower bound, not a global total; worth
confirming against the backend before we lean on it further.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017R8mua9xepzF3mnRETtd6W
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 491bb729-0015-4bf9-a598-9a93d2abda6a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant