refactor(web): share one track row and media action hook #96

Merged
joshuafhiggins merged 2 commits from t3/consolidate-web-track-rows into main 2026-11-16 21:48:19 -05:00
Owner

The web app had four near-identical track row components (songs, playlist, album, queue), each re-implementing the cover, favorite star and explicit badge, plus five copies of the handleMediaAction switch. Searching a playlist also renumbered tracks from 1 instead of showing their playlist position.

  • components/track-row.tsx: one memoized TrackRow with a variant (library, album, playlist, queue). Callbacks take the row index or song id, so views pass one stable handler for every row (works for the virtualized SongsView).
  • hooks/use-media-actions.ts: useMediaActions (song and artist actions) and useTrackListMediaAction (targets the selection or the row's song, resolves the station artist).
  • selection-range-styles.tsx: the songs/queue highlight copies collapse into a flush prop.
  • Playlist rows show their real position while filtering; drag to reorder stays disabled while filtering.

Small differences: playlist rows now show the explicit badge like the other lists. track-row.tsx keeps a local formatDuration, which #94 can fold into the shared helper.

Verified in headless Chrome against the test server: songs (range select, multi-select menu counts, double-click play), album, playlist (search keeps track number 41, rows not draggable while filtered), artist pages and the queue panel. Web typecheck and lint pass.

Made by Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

The web app had four near-identical track row components (songs, playlist, album, queue), each re-implementing the cover, favorite star and explicit badge, plus five copies of the `handleMediaAction` switch. Searching a playlist also renumbered tracks from 1 instead of showing their playlist position. - `components/track-row.tsx`: one memoized `TrackRow` with a `variant` (`library`, `album`, `playlist`, `queue`). Callbacks take the row index or song id, so views pass one stable handler for every row (works for the virtualized `SongsView`). - `hooks/use-media-actions.ts`: `useMediaActions` (song and artist actions) and `useTrackListMediaAction` (targets the selection or the row's song, resolves the station artist). - `selection-range-styles.tsx`: the songs/queue highlight copies collapse into a `flush` prop. - Playlist rows show their real position while filtering; drag to reorder stays disabled while filtering. Small differences: playlist rows now show the explicit badge like the other lists. `track-row.tsx` keeps a local `formatDuration`, which #94 can fold into the shared helper. Verified in headless Chrome against the test server: songs (range select, multi-select menu counts, double-click play), album, playlist (search keeps track number 41, rows not draggable while filtered), artist pages and the queue panel. Web typecheck and lint pass. Made by Claude Opus 5.5 in Claude Code (T3 Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
joshuafhiggins added 1 commit 2026-11-16 13:56:50 -05:00
Replace SongRow, PlaylistSongRow, album TrackRow and QueueSongRow with a
memoized TrackRow that takes a variant, and replace the five
handleMediaAction switches with useMediaActions/useTrackListMediaAction.

Playlist rows now show each song's real playlist position while filtering
instead of renumbering from 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joshuafhiggins added 1 commit 2026-11-16 21:48:13 -05:00
# Conflicts:
#	apps/web/components/album-view.tsx
#	apps/web/components/playlist-view.tsx
#	apps/web/components/songs-view.tsx
#	apps/web/lib/selection-range-styles.tsx
joshuafhiggins merged commit d395273691 into main 2026-11-16 21:48:19 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joshuafhiggins/otunes#96