gitoria

jukebox

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit7eb2898d7eb2898dRecords: mpackdb second-opener rule until day38mre7eb2898d/lib/remember.hl

1.1 KB

  1. // lib/remember.hl — WHAT THE LISTENER LAST CHOSE, kept in storage/ui.json: the sort of the Songs screen (artist, title, album, plays).
  2. // The screen opens the way it was left. Its own file, apart from settings.json (that one holds the library paths and is written whole by the settings call).
  3. import { readFile, writeFile, exists, mkDir } from 'hl:fs'
  4. import { storageRoot, storageDir } from './util.hl'
  5. static uiFile = storageRoot + '/ui.json'
  6. static sorts = ['artist', 'title', 'album', 'plays']
  7. // the sort the Songs screen was left with ('artist' when nothing was saved or the file says something else)
  8. static lastSort = () => {
  9. if (!exists(uiFile)) { return 'artist' }
  10. text = readFile(uiFile)
  11. if (text == null || !text.trim().startsWith('{')) { return 'artist' }
  12. j = JSON.parse(text)
  13. if (j == null || j.sort == null || !sorts.includes(j.sort)) { return 'artist' }
  14. return j.sort
  15. }
  16. // the listener chose a sort: keep it for the next visit; a name that is no sort is ignored
  17. static rememberSort = (sort) => {
  18. if (sort == null || !sorts.includes(sort)) { return null }
  19. mkDir(storageRoot)
  20. writeFile(uiFile, JSON.stringify({ sort = sort }), 420)
  21. return sort
  22. }

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