jukebox
All repositories: gitoria
1.1 KB
// lib/remember.hl — WHAT THE LISTENER LAST CHOSE, kept in storage/ui.json: the sort of the Songs screen (artist, title, album, plays).// 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).import { readFile, writeFile, exists, mkDir } from 'hl:fs'import { storageRoot, storageDir } from './util.hl'static uiFile = storageRoot + '/ui.json'static sorts = ['artist', 'title', 'album', 'plays']// the sort the Songs screen was left with ('artist' when nothing was saved or the file says something else)static lastSort = () => {if (!exists(uiFile)) { return 'artist' }text = readFile(uiFile)if (text == null || !text.trim().startsWith('{')) { return 'artist' }j = JSON.parse(text)if (j == null || j.sort == null || !sorts.includes(j.sort)) { return 'artist' }return j.sort}// the listener chose a sort: keep it for the next visit; a name that is no sort is ignoredstatic rememberSort = (sort) => {if (sort == null || !sorts.includes(sort)) { return null }mkDir(storageRoot)writeFile(uiFile, JSON.stringify({ sort = sort }), 420)return sort}
Branches
Latest commits
- d3df773cMission 005: doc linemre
- 6a5d840aMission 005: jukebox#22mre
- 13e5e748Records: mission 004 startedmre
- a8098271Mission 004: jukebox#21mre
- df8f5205Records: jukebox#19-21, #11 closedmre
- b7a4e692Records: hybriel#298mre
- 9bcbb017Records: day38b waits for day39 fixmre
- f80504e1Records: day38b repro sentmre
- 8048258bRecords: day38b jb3 regression, L1 Chromes stoppedmre
- 68aace7fRecords: mission 003 day38bmre
- d105d8a9Records: mpackdb integrity check cleanmre
- 6e980c53Records: mpackdb rule refinementmre
- 6d335ac4Records: storage copy rulingmre
- 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