gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd1a91be9d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmred1a91be9/components/schedule.hl

4.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. // Insert once into the caller's list; equal release dates retain the old reverse-insertion order.
  20. static insertByReleaseAsc = (&sorted, &row) => {
  21. let low = 0
  22. let high = sorted.length
  23. while (low < high) {
  24. middle = (low + high - (low + high) % 2) / 2
  25. if (row.release <= sorted[middle].release) { high = middle }
  26. else { low = middle + 1 }
  27. }
  28. sorted.splice(low, 0, row)
  29. return null
  30. }
  31. static scheduleRowsOf = (&userId) => {
  32. if (userId == null) { return [] }
  33. today = todayStr()
  34. out = []
  35. // tracker#30 (mission 025): the slim cached card + episode rows per followed title (shows.hl), no record fetched per load
  36. for (sid of followedShowIds(&userId)) {
  37. c = cardOf(&sid)
  38. if (c != null) {
  39. for (e of episodeRowsOf(&sid)) {
  40. upcoming = e.release != null && e.release > today
  41. if (upcoming) {
  42. insertByReleaseAsc(&out, {
  43. id = e.id showTitle = c.titleYear showHref = c.href
  44. episodeLabel = episodeCode(&e.s, &e.e) + ' · ' + e.title
  45. release = e.release
  46. })
  47. }
  48. }
  49. }
  50. }
  51. return out
  52. }
  53. // ---- reactive members -----------------------------------------------------------------------
  54. session = null
  55. userId = userIdOfSession(&session)
  56. signedIn = userId != null
  57. // a plain copy of userId for `rows` (mission 047: session sync, see components/show.hl `me`)
  58. me = userId
  59. rows = signedIn ? scheduleRowsOf(&me) : []
  60. hasRows = rows.length > 0
  61. noRows = !hasRows
  62. emptyText = signedIn ? 'No upcoming episodes.' : 'Sign in to see the shows you follow.'
  63. __title = 'Schedule — ' + appTitle
  64. // HM49: component rules keep the existing selectors and shared theme variables.
  65. Style {
  66. schedulePage {
  67. display = 'block'
  68. }
  69. scheduleRows {
  70. display = 'block'
  71. }
  72. scheduleRow {
  73. display = 'grid'
  74. gridTemplateColumns = 'minmax(0, 1fr) auto'
  75. alignItems = 'center'
  76. gap = '0 .6rem'
  77. padding = '.5rem 0'
  78. @media {
  79. minWidth = '40rem'
  80. display = 'flex'
  81. }
  82. }
  83. scheduleShow {
  84. fontWeight = '600'
  85. overflowWrap = 'anywhere'
  86. padding = '.7rem 0'
  87. margin = '-.7rem 0'
  88. @media {
  89. minWidth = '40rem'
  90. flex = 'none'
  91. }
  92. }
  93. scheduleEpisode {
  94. gridColumn = '1 / 3'
  95. gridRow = '2'
  96. color = 'var(--color-text)'
  97. overflowWrap = 'anywhere'
  98. @media {
  99. minWidth = '40rem'
  100. flex = '1'
  101. }
  102. }
  103. scheduleDate {
  104. gridRow = '1'
  105. gridColumn = '2'
  106. fontSize = '.85rem'
  107. color = 'var(--color-text-muted)'
  108. fontVariantNumeric = 'tabular-nums'
  109. @media {
  110. minWidth = '40rem'
  111. flex = 'none'
  112. }
  113. }
  114. }
  115. View {
  116. schedulePage {
  117. h1 { "Schedule" }
  118. if (noRows) { p { class = "muted" emptyText } }
  119. if (hasRows) {
  120. scheduleRows {
  121. for (row of rows) {
  122. scheduleRow {
  123. a { Style.scheduleShow href = row.showHref row.showTitle }
  124. scheduleEpisode { row.episodeLabel }
  125. scheduleDate { row.release }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }

Branches

Latest commits

  • d1a91be9Merge hm57-let: tracker#57 let only for reassigned namesmre
  • a404ed75Report HM57 audit, gates and integration notesmre
  • 1dcb87a7Use plain declarations for unchanged bindingsmre
  • b90395e3log: HM51 mergedmre
  • 9888d076Merge hm51-classes: tracker#51 views use Style referencesmre
  • 4399bc2fReference remaining component-owned root Style rulesmre
  • 9edcc2dflog: #58 live, HM57 startedmre
  • 73fa20ddMerge hm49b-styles: tracker#49 rest of the component stylesmre
  • aed12917Reference owned Style rules in genres and searchmre
  • 14195720log: HM49B done, HM51 startedmre
  • 78ee6b56Move remaining component styles into Style blocksmre
  • 7f04de33log: HM49Bmre
  • 00616cf3log: #49 batch merged, DP67 startedmre
  • d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
  • 079f376dMove seven components' styles into Style blocksmre
  • 17d66feelog: #58 mergedmre
  • 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
  • a85f7900Move route logic out of the project mapmre
  • 13dea5belog: #56 live, HM49 and HM58 startedmre
  • a31c8f2fdocs: tracker#36 remaining listmre