Skip to content

feat(library): show view count on published clips' cards - #65

Merged
DarrellVS merged 1 commit into
devfrom
feat/card-view-count
Sep 23, 2026
Merged

DarrellVS merged 1 commit into
devfrom
feat/card-view-count

Conversation

@DarrellVS

Copy link
Copy Markdown
Owner

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

  • No per-page fetch. publisherViews / publisherLastViewedAt were already mirrored onto every row by SyncPublisherStatsAction and already in ClipDTO, so every library page carries them.
  • Freshness was the gap. The sync ran at boot and on the Publisher screen only. useLibraryViewCounts now asks on library open and on window focus with maxAgeMs; 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.
  • Patch, not refetch. clipsStore.applyPublisherViews assigns 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.
  • Quiet on failure. An unreachable publisher leaves the last numbers; the Publisher screen is where that is explained.
  • Null and zero both say nothing on a card. A card cannot tell "never opened" from "nothing was counting yet"; the Publisher screen knows countingSince and says both.

Testing

  • npm run check: typecheck and 875 unit tests green. New: viewCount.spec.ts (label) and publisherStatsFreshness.spec.ts (throttle). The zero rule was mutated to confirm its test fails.
  • e2e not run and no e2e spec added: the suite is being reworked in parallel.

🤖 Generated with Claude Code

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>
@DarrellVS DarrellVS added the enhancement New feature or request label Sep 23, 2026
@DarrellVS
DarrellVS merged commit 3c68cae into dev Sep 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant