gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit0923398b0923398bMerge branch 'records-1124d' into mainJukebox0923398b/components/artist.hl

3.1 KB

  1. // 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).
  2. parent './main.hl'
  3. import { navigate } from 'hl:web'
  4. import VirtualList from './virtual-list/virtual-list.hl'
  5. import { rowsFor, artistInfo } from '../lib/rows.hl'
  6. import { lastScroll, rememberScroll, startRowFor } from '../lib/remember.hl'
  7. id = null
  8. info = artistInfo(id)
  9. __title = info.name + ' · Jukebox'
  10. String tab = info.albums > 1 ? 'albums' : 'songs'
  11. Hybrid artistCtx = { kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  12. // where this artist's list was left (lib/remember.hl, keyed by the artist's id and the tab shown)
  13. Number savedTop = lastScroll('artist:' + id + ':' + tab)
  14. Number firstRow = startRowFor(savedTop)
  15. Hybrid firstRows = rowsFor({ kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }, firstRow, 100)
  16. Number listTotal = firstRows.total
  17. Hybrid chunk = firstRows.rows
  18. Number chunkFrom = firstRows.offset
  19. String listResetKey = ''
  20. String playingId = ''
  21. String albumsClass = tab == 'albums' ? 'on' : ''
  22. String songsClass = tab == 'songs' ? 'on' : ''
  23. on artistLoad(first, wanted) {
  24. let start = first - 20
  25. if (start < 0) { start = 0 }
  26. r = emit server artistRows(artistCtx, start, 100)
  27. listTotal = r.total
  28. chunk = r.rows
  29. chunkFrom = r.offset
  30. return null
  31. }
  32. on server artistRememberScroll(key, top) {
  33. return rememberScroll(key, top)
  34. }
  35. on artistScrolled(top) {
  36. emit server artistRememberScroll('artist:' + id + ':' + tab, top)
  37. return null
  38. }
  39. rememberTop = (top) => { emit artistScrolled(top) }
  40. loadRange = (first, wanted) => { emit artistLoad(first, wanted) }
  41. picked = (String rowId, Number index) => {
  42. if (tab == 'albums') { navigate('/albums/' + rowId) } else {
  43. playingId = rowId
  44. $parent.jbPlay(artistCtx, index, rowId)
  45. emit artistLoad(index, 0)
  46. }
  47. }
  48. on artistShuffle(Hybrid e) {
  49. $parent.jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })
  50. return null
  51. }
  52. on artistTab(e) {
  53. tab = e.target.getAttribute('data-tab')
  54. artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  55. r = emit server artistRows(artistCtx, 0, 100)
  56. listTotal = r.total
  57. chunk = r.rows
  58. chunkFrom = 0
  59. savedTop = 0
  60. listResetKey = id + ':' + tab
  61. return null
  62. }
  63. View {
  64. jbScreen {
  65. jbTabs {
  66. button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }
  67. button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }
  68. button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }
  69. }
  70. VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId scrollTop = savedTop onScroll = rememberTop resetKey = listResetKey listLabel = "Artist"
  71. jbHead { h1 { id = "name" info.name } p { info.line } }
  72. }
  73. }
  74. }
  75. // This screen owns its row request across the server boundary.
  76. on server artistRows(Hybrid ctx, Number offset, Number limit) {
  77. return rowsFor(ctx, offset, limit)
  78. }

Branches

Latest commits

  • 0923398bMerge branch 'records-1124d' into mainJukebox
  • 78f0cc86|||PR records 2026-11-24: inbox-thread rule, "Not playing" confirmed and closedmre
  • c1b153c4Merge branch 'records-1124c' into mainJukebox
  • d7b5e780|||PR Records 2026-11-24 (2): live day72, PR #19 merge, #10 newsmre
  • 43b564dbMerge branch 'records-1124b' into mainJukebox
  • fa86b08c|||PR Records 2026-11-24: LOG, STATUS, missions 020-023mre
  • 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