gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchcode-order95f5faae|||PR jukebox#7 Drop needless let declarationsmrecode-order/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 playingId = ''
  20. String albumsClass = tab == 'albums' ? 'on' : ''
  21. String songsClass = tab == 'songs' ? 'on' : ''
  22. on artistLoad(first, wanted) {
  23. let start = first - 20
  24. if (start < 0) { start = 0 }
  25. r = emit server artistRows(artistCtx, start, 100)
  26. listTotal = r.total
  27. chunk = r.rows
  28. chunkFrom = r.offset
  29. return null
  30. }
  31. on server artistRememberScroll(key, top) {
  32. return rememberScroll(key, top)
  33. }
  34. on artistScrolled(top) {
  35. emit server artistRememberScroll('artist:' + id + ':' + tab, top)
  36. return null
  37. }
  38. rememberTop = (top) => { emit artistScrolled(top) }
  39. loadRange = (first, wanted) => { emit artistLoad(first, wanted) }
  40. picked = (String rowId, Number index) => {
  41. if (tab == 'albums') { navigate('/albums/' + rowId) } else {
  42. playingId = rowId
  43. $parent.jbPlay(artistCtx, index, rowId)
  44. emit artistLoad(index, 0)
  45. }
  46. }
  47. on artistShuffle(Hybrid e) {
  48. $parent.jbShuffle({ kind = 'list' ctx = { kind = 'artist-songs' artist = id sort = 'artist' } })
  49. return null
  50. }
  51. on artistTab(e) {
  52. tab = e.target.getAttribute('data-tab')
  53. artistCtx = { kind = tab == 'albums' ? 'artist-albums' : 'artist-songs' artist = id sort = 'artist' }
  54. r = emit server artistRows(artistCtx, 0, 100)
  55. listTotal = r.total
  56. chunk = r.rows
  57. chunkFrom = 0
  58. emit vlTop()
  59. return null
  60. }
  61. View {
  62. jbScreen {
  63. jbTabs {
  64. button { type = "button" class = albumsClass 'data-tab' = "albums" on click(e) { emit artistTab(e) } "Albums" }
  65. button { type = "button" class = songsClass 'data-tab' = "songs" on click(e) { emit artistTab(e) } "Songs" }
  66. button { id = "shuffle" type = "button" on click(e) { emit artistShuffle(e) } "Shuffle" }
  67. }
  68. VirtualList { itemCount = listTotal rowHeight = 56 loaded = chunk loadedFrom = chunkFrom onRange = loadRange onPick = picked selectedId = playingId scrollTop = savedTop onScroll = rememberTop listLabel = "Artist"
  69. jbHead { h1 { id = "name" info.name } p { info.line } }
  70. }
  71. }
  72. }
  73. // This screen owns its row request across the server boundary.
  74. on server artistRows(Hybrid ctx, Number offset, Number limit) {
  75. return rowsFor(ctx, offset, limit)
  76. }

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