gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite6cf03ffe6cf03ffmission RV28d: rv28c onto day38bmree6cf03ff/components/schedule.hl

3.1 KB

  1. // components/schedule.hl — `/my/schedule` (tracker.worldapi.org#6, moved from `/schedule` in #8): every episode of a show the signed-in
  2. // user follows that is not yet released, soonest first. Creator's words: "/schedule has a similar list
  3. // without check icons for he upcoming episodes of shows followed". Same row shape as /unwatched (step 5)
  4. // minus the check icon and minus any click handling — this page is read-only, so it needs no `on server`
  5. // face at all. Reused (not copied) from follows.hl/shows.hl: `followedShowIds`, `cardOf`, `episodeRowsOf`
  6. // — the same functions /unwatched already imports.
  7. //
  8. // Upcoming = release date strictly AFTER today (the architect's reading of the ticket: "the creator named
  9. // the order only for /unwatched" — /unwatched is release <= today, so the natural complement here is
  10. // release > today; an episode releasing today already belongs to /unwatched once watched state is added).
  11. parent './main.hl'
  12. import { appTitle } from '../project.hl'
  13. import { userIdOfSession } from '../lib/users.hl'
  14. import { followedShowIds } from '../lib/follows.hl'
  15. import { cardOf, episodeRowsOf, episodeCode } from '../lib/shows.hl'
  16. import { todayStr } from '../lib/util.hl'
  17. // ---- pure helpers (static: an mpackdb-backed helper must be `static` to stay callable outside its
  18. // own initializer, hybriel#115/#116 — see components/unwatched.hl's header comment) --------------
  19. // insertion sort, hand-written (no list sort(), hybriel#1) — soonest release first
  20. static insertByReleaseAsc = (&sorted, &row) => {
  21. out = []
  22. let inserted = false
  23. for (x of sorted) {
  24. if (!inserted && row.release <= x.release) { out.push(row) inserted = true }
  25. out.push(x)
  26. }
  27. if (!inserted) { out.push(row) }
  28. return out
  29. }
  30. static scheduleRowsOf = (&userId) => {
  31. if (userId == null) { return [] }
  32. today = todayStr()
  33. let out = []
  34. // tracker#30 (mission 025): the slim cached card + episode rows per followed title (shows.hl), no record fetched per load
  35. for (sid of followedShowIds(userId)) {
  36. let c = cardOf(sid)
  37. if (c != null) {
  38. for (e of episodeRowsOf(sid)) {
  39. let upcoming = e.release != null && e.release > today
  40. if (upcoming) {
  41. out = insertByReleaseAsc(out, {
  42. id = e.id showTitle = c.titleYear showHref = c.href
  43. episodeLabel = episodeCode(e.s, e.e) + ' · ' + e.title
  44. release = e.release
  45. })
  46. }
  47. }
  48. }
  49. }
  50. return out
  51. }
  52. // ---- reactive members -----------------------------------------------------------------------
  53. session = null
  54. userId = userIdOfSession(session)
  55. signedIn = userId != null
  56. // a plain copy of userId for `rows` (mission 047: session sync, see components/show.hl `me`)
  57. me = userId
  58. rows = signedIn ? scheduleRowsOf(me) : []
  59. hasRows = rows.length > 0
  60. noRows = !hasRows
  61. emptyText = signedIn ? 'No upcoming episodes.' : 'Sign in to see the shows you follow.'
  62. __title = 'Schedule — ' + appTitle
  63. View {
  64. schedulePage {
  65. h1 { "Schedule" }
  66. if (noRows) { p { class = "muted" emptyText } }
  67. if (hasRows) {
  68. scheduleRows {
  69. for (row of rows) {
  70. scheduleRow {
  71. a { class = "schedule-show" href = row.showHref row.showTitle }
  72. scheduleEpisode { row.episodeLabel }
  73. scheduleDate { row.release }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }

Branches

Latest commits

  • e6cf03ffmission RV28d: rv28c onto day38bmre
  • 3ccaee19status: live sweep freeze, waiting for Apollomre
  • 49f76ecblog: watch toggle slowness = session sweep freeze (tracker#50)mre
  • 3daf6eddlog: day37 live, still waiting for day39mre
  • 796ba672records: #277 slips to day39mre
  • a9eb9827records: mpackdb integrity clean, all 12 tablesmre
  • 6cf40dbdrecords: mpackdb integrity check, shows uncheckedmre
  • 1880f42arecords: day38 deploy may swap normallymre
  • 9d806e35records: mpackdb freeze until day38mre
  • a660239drecords: day37 lacks #277, wait for day38mre
  • b0abfdeaLOG: Anton hybriel#277 fix ready for day37mre
  • 7b5b2918Tracker: hybriel#277 fix comes in day37mre
  • 7ddbeec8Tracker: RV28c blocked on day35 regressionmre
  • bf401884Tracker: RV28c startedmre
  • 0ff4ecd4Tracker: RV28c briefmre
  • 06565b1fRecords: day35 relay note, tickets subscription idmre
  • c6dc3e86RV28b: switch to set day35mre
  • 24e401b8Tracker: TR7 watch cleanmre
  • b0412957Tracker: RV28b handed overmre
  • 456940c8Tracker: RULINGS pathmre