jukebox
All repositories: gitoria
3.1 KB
// components/artist.hl — `/artists/<id>`: one artist, with a switch between their albums and their songs (both are long lists for some artists, so both are virtual lists).parent './main.hl'import { navigate } from 'hl:web'import VirtualList from './virtual-list/virtual-list.hl'import { rowsFor, artistInfo } from '../lib/rows.hl'import { lastScroll, rememberScroll, startRowFor } from '../lib/remember.hl'id = nullinfo = artistInfo(id)__title = info.name + ' · Jukebox'String tab = info.albums > 1 ? 'albums' : 'songs'Hybrid artistCtx = { kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }// where this artist's list was left (lib/remember.hl, keyed by the artist's id and the tab shown)Number savedTop = lastScroll('artist:' + id + ':' + tab)Number firstRow = startRowFor(savedTop)Hybrid firstRows = rowsFor({ kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }, firstRow, 100)Number listTotal = firstRows.totalHybrid chunk = firstRows.rowsNumber chunkFrom = firstRows.offsetString playingId = ''String albumsClass = tab == 'albums' ? 'on' : ''String songsClass = tab == 'songs' ? 'on' : ''on artistLoad(first, wanted) {let start = first - 20if (start < 0) { start = 0 }r = emit server artistRows(artistCtx, start, 100)listTotal = r.totalchunk = r.rowschunkFrom = r.offsetreturn null}on server artistRememberScroll(key, top) {return rememberScroll(key, top)}on artistScrolled(top) {emit server artistRememberScroll('artist:' + id + ':' + tab, top)return null}rememberTop = (top) => { emit artistScrolled(top) }loadRange = (first, wanted) => { emit artistLoad(first, wanted) }picked = (String rowId, Number index) => {if (tab == 'albums') { navigate('/albums/' + rowId) } else {playingId = rowId$parent.jbPlay(artistCtx, index, rowId)emit artistLoad(index, 0)}}on artistShuffle(Hybrid e) {$parent.jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })return null}on artistTab(e) {tab = e.target.getAttribute('data-tab')artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }r = emit server artistRows(artistCtx, 0, 100)listTotal = r.totalchunk = r.rowschunkFrom = 0emit vlTop()return null}View {jbScreen {jbTabs {button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }}VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId scrollTop = savedTop onScroll = rememberTop listLabel = "Artist"jbHead { h1 { id = "name" info.name } p { info.line } }}}}// This screen owns its row request across the server boundary.on server artistRows(Hybrid ctx, Number offset, Number limit) {return rowsFor(ctx, offset, limit)}
Branches
Latest commits
- 95f5faae|||PR jukebox#7 Drop needless let declarationsmre
- 33072bb5|||PR Record day72 gates and Chrome proofmre
- 95f2cd73|||PR Use typed parent methods for screen playback and local server facesmre
- 6422a020Sync media-player at 51c3818mre
- b582ba1cVendor complete Hybriel day72 plugin setmre
- 02dccbc9Merge branch 'records-1119' into mainJukebox
- a39e1c23|||PR Records: missions 013-015, reconnect fix livemre
- fc7db075Merge branch 'reconnect-retry' into mainJukebox
- ac6f4c6fL2: plain declaration for a in pickedNextmre
- 2f335086Review round 2: only an explicit queue pick drops pend (not the automatic advance); jb23 records every source changemre
- 3eb6695fReview fixes: action generation, queue pick clears pend, Previous/Next retry the decided request, typed handlersmre
- 7a53c0c2|||PR A tap lost to a dead socket plays after reconnect (mission 015)mre
- 1f0cd77bMerge branch 'records-day41' into mainJukebox
- 67be229f|||PR Records: day41 live (PR #4), mission 012, statusmre
- 0bb027daconductor: caramboleyo is the user, not owner/creatorApollo
- 04f5d9d5Merge branch 'day41' into mainJukebox
- 8ed6da45|||PR README: media-player pin df9e7dfmre
- d5d45fc3|||PR media-player df9e7df (repeat-one fix), sync pin and SOURCEmre
- 89cdabb1Vendor Hybriel day41 (57054d9e): plugin dirs, set .somre
- 1fecd6a7Merge branch 'records-day39' into mainJukebox