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 listResetKey = ''String 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 = 0savedTop = 0listResetKey = id + ':' + tabreturn 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 resetKey = listResetKey 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
- 0a2ae3daMerge remote-tracking branch 'origin/records-1123' into records-1124mre
- 9a48cfcaMerge branch 'vendor-theme' into mainJukebox
- 170d3735Merge branch 'code-order-2' into mainJukebox
- 3f1918a7|||PR Re-sync layouts theme 4099e64 with Segoe UI firstmre
- 2e7f6a43Vendor virtual-list 489afcf from components.hybrielmre
- 0ba85799Merge branch 'reset-classes' into mainJukebox
- 502eeed5jukebox#20: vendor virtual-list initial resetKey baseline fixmre
- 6d5ce287|||PR jukebox#9 Centralize songs table reads and writes in db.hlmre
- dcca21abjukebox#8 Move copies and queue logic into their topicsmre
- 3b76651cjukebox#20: update virtual-list README pin and resetKey optionsmre
- bc09e1e8|||PR jukebox#20: reset virtual lists through resetKey (partial validation)mre
- a3796dc5Records: live step waits for idlemre
- 3b158e16Records: merges of #9 and #11mre
- 27204167Merge main into records-1123mre
- 10f8a8c8Merge branch 'code-order' into mainJukebox
- 204fc828Merge branch 'day72' into mainJukebox
- 8e8d0e2b|||PR Records: PROCEDURES.md, missions 016-019, GO 2026-11-23mre
- 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