gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita01f3aa8a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mrea01f3aa8/lib/plays.hl

1.3 KB

  1. // lib/plays.hl — THE JUKEBOX'S OWN PLAY COUNTS. The file's counter (POPM / PCNT) is the starting value and is never written back; every play the jukebox itself
  2. // counts adds 1 here, in the jukebox database (table plays, key = the song id). A song's play count for Favourites and sorting is the file's count + this one.
  3. import { playsTable } from './db.hl'
  4. import { cache, dropOrderCache } from './state.hl'
  5. import { songsTable } from './db.hl'
  6. // the map song id → counter, loaded once and kept in step with the table
  7. static counts = () => {
  8. if (cache.jb != null) { return cache.jb }
  9. m = {}
  10. for (r of playsTable.range('id', null, null)) { m[r.id] = r.count }
  11. cache.jb = m
  12. return m
  13. }
  14. static jbCount = (id) => {
  15. c = counts()[id]
  16. return c == null ? 0 : c
  17. }
  18. // count one play of a song: answers the new counter
  19. static addPlay = (id, now) => {
  20. m = counts()
  21. n = (m[id] == null ? 0 : m[id]) + 1
  22. if (playsTable.fetch(id) == null) { playsTable.put({ id = id count = n at = now }) } else { playsTable.update(id, { id = id count = n at = now }) }
  23. m[id] = n
  24. cache.jb = m
  25. return n
  26. }
  27. // the browser says a song was listened to long enough: count it. Answers { id, filePlays, jukeboxPlays } or null for an unknown song
  28. static countPlay = (id, now) => {
  29. s = songsTable.fetch(id)
  30. if (s == null) { return null }
  31. n = addPlay(s.id, now)
  32. dropOrderCache()
  33. return { id = s.id filePlays = s.playCount jukeboxPlays = n }
  34. }

Branches

Latest commits

  • a01f3aa8ui gate: back to the top before the sort checks (the screen reopens where it was left)mre
  • f7936c20Lists keep their scroll position across a reload (jukebox#20): per-list offsets in storage/ui.json, gate jb20mre
  • d67906devirtual-list and icons from components.hybriel e5b98ec (centerId, scrollTop, onScroll)mre
  • df7920ceRecords: R3 startedmre
  • 0549f038Mission 010: jb20 livemre
  • 273494e2STATUS rewrittenmre
  • 227c9b96Records: jb19 livemre
  • 9f365376README: the bar's controls (jb19)mre
  • d18851fdjb19: pressed switches look different (whole selector), queue column cannot widen past the panel, gates follow the new bar (jb3, jb11, jb15)mre
  • 82b54c0ejb19: bar Shuffle · Previous · Play · Next · Repeat, no 10 s buttons; Shuffle switch (shuffle from the playing song, back to the list), Repeat off/all/one, both remembered in ui.json; Shuffle my favourites an ordinary button; gate tests/jb19.mjsmre
  • ba354710jb19: icons pinned to components.hybriel 46fefaa (shuffle, repeat, repeatOne, prevTrack, nextTrack)mre
  • d8e8d059jb19 step 2: media-player from components.hybriel c96709c (skip, repeat options; the end of a song only calls onPlay), sync-components.sh and SOURCE point to it, jb11 counts media loads and metadata writes (from jb21 d3a026e)mre
  • 7b048c1bRecords: jb19 done, L2 live stepmre
  • 665185aeMission 009: jb19 livemre
  • 47b2d3beRecords: P1 resumedmre
  • 8e326e94Records: resetKey blockedmre
  • f72dd7edRecords: icons comingmre
  • b264e5deRecords: P1 icons stopmre
  • 514d7cbeRecords: mission 008 startedmre
  • 61c40127Mission 008: #19 + #21mre