feat(library): show view count on published clips' cards - #65
Merged
Merged
Conversation
The counts were already mirrored onto every clip row, so no per-page fetch: the card reads publisherViews off the row it already has. What was missing was freshness, since the sync only ran at boot and on the Publisher screen. The library now asks on open and on window focus, throttled in main to one request per ten minutes shared with every other caller, and patches the rows on screen rather than refetching. Null and zero both show nothing on a card: a card cannot tell "never opened" from "nothing was counting yet". Closes #63 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Closes #63.
What
A published clip's card shows how often it has been opened, last on the metadata line:
0:21 · Battlefield 6 · 2 days ago · 87.2 MB · 37 views. Hover shows when it was last opened.How
publisherViews/publisherLastViewedAtwere already mirrored onto every row bySyncPublisherStatsActionand already inClipDTO, so every library page carries them.useLibraryViewCountsnow asks on library open and on window focus withmaxAgeMs; main answers from the last attempt when it is inside ten minutes (statsAreStale, one clock shared by every caller, attempts count as well as successes) and collapses concurrent calls onto the one in flight. The Publisher screen passes nothing and always asks, as before.clipsStore.applyPublisherViewsassigns the two fields on rows already on screen, after the page's own first fetch has landed, so the grid does not jump and the requestId pattern is not raced.countingSinceand says both.Testing
npm run check: typecheck and 875 unit tests green. New:viewCount.spec.ts(label) andpublisherStatsFreshness.spec.ts(throttle). The zero rule was mutated to confirm its test fails.🤖 Generated with Claude Code