gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit7eb2898d7eb2898dRecords: mpackdb second-opener rule until day38mre7eb2898d/components/artist.hl

2.3 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. id = null
  7. info = artistInfo(id)
  8. __title = info.name + ' · Jukebox'
  9. String tab = info.albums > 1 ? 'albums' : 'songs'
  10. Hybrid artistCtx = { kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  11. Hybrid firstRows = rowsFor({ kind = info.albums > 1 ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }, 0, 100)
  12. Number listTotal = firstRows.total
  13. Hybrid chunk = firstRows.rows
  14. Number chunkFrom = 0
  15. String playingId = ''
  16. String albumsClass = tab == 'albums' ? 'on' : ''
  17. String songsClass = tab == 'songs' ? 'on' : ''
  18. on artistLoad(first, wanted) {
  19. let start = first - 20
  20. if (start < 0) { start = 0 }
  21. r = emit server jbRows(artistCtx, start, 100)
  22. listTotal = r.total
  23. chunk = r.rows
  24. chunkFrom = r.offset
  25. return null
  26. }
  27. loadRange = (first, wanted) => { emit artistLoad(first, wanted) }
  28. picked = (rowId, index) => {
  29. if (tab == 'albums') { navigate('/albums/' + rowId) } else {
  30. playingId = rowId
  31. emit jbPlay(artistCtx, index, rowId)
  32. emit artistLoad(index, 0)
  33. }
  34. }
  35. on artistShuffle(e) {
  36. emit jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })
  37. return null
  38. }
  39. on artistTab(e) {
  40. tab = e.target.getAttribute('data-tab')
  41. artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  42. r = emit server jbRows(artistCtx, 0, 100)
  43. listTotal = r.total
  44. chunk = r.rows
  45. chunkFrom = 0
  46. emit vlTop()
  47. return null
  48. }
  49. View {
  50. jbScreen {
  51. jbTabs {
  52. button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }
  53. button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }
  54. button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }
  55. }
  56. VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId listLabel = "Artist"
  57. jbHead { h1 { id = "name" info.name } p { info.line } }
  58. }
  59. }
  60. }

Branches

Latest commits

  • 7eb2898dRecords: mpackdb second-opener rule until day38mre
  • b011f98eRecords: style form live on day35mre
  • 60d90cb2Records: L1 woken for the restartmre
  • 75ae544fRecords: restart waits for the connection to closemre
  • e0b75951Records: L1 merged and pushed, restart waits for an open connectionmre
  • f2b5db98styles: format styles with nested rules and bare queriesmre
  • f036bab4search: format styles with nested rules and bare queriesmre
  • ef9a9d4asongs: format styles with nested rules and bare queriesmre
  • f22f9aacmain: format styles with nested rules and bare queriesmre
  • f56cd7c7Sync icons from 8176eb1 and verify mixed component sourcesmre
  • d56e5054Sync theme and shared tokens from layouts 17e0f03mre
  • b1362547Re-vendor to Hybriel set day35mre
  • 89e10f08Records: mission 002 rollback wordingmre
  • 9485dee7Records: mission 002 brief (live step)mre
  • 9ba68fe7Records: S1b reviewedmre
  • 193dfff1Records: S1 result, S1b startedmre
  • 028ed776Records: mission 001 continuation S1bmre
  • 1838d7e8Records: S1 startedmre
  • a43fca3fRecords: mission 001 decided pointsmre
  • 41773828Records: statusmre