gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit85cfb4ae85cfb4ae|||PR records: AP61 day61, DP74 liveTracker85cfb4ae/components/unwatched.hl

4.2 KB

  1. // components/unwatched.hl — `/my/unwatched` (tracker.worldapi.org#5, moved from `/unwatched` in #8): every already-released episode of a
  2. // show the signed-in user follows that they have not watched yet, newest release first. Creator's words:
  3. // "/unwatched lists all unwatched episodes of shows followed in release date desc order"; "check icon is
  4. // a disc with a check in it" — the SAME check icon and watch logic as the show page (step 4), reused
  5. // (not copied) from follows.hl/shows.hl/watches.hl: `watchClassOf`, `watchedSet`, `setWatched` come from
  6. // watches.hl, the check icon markup/CSS is the same `button.checkicon` shape/class styles.hl already has.
  7. //
  8. // A ROW ONLY EVER SHOWS AN UNWATCHED EPISODE, so a click always marks it watched (never toggles back,
  9. // unlike the show page's checks) and the row leaves the list — the ticket's own test: "click an
  10. // episode's check: it disappears from the list."
  11. //
  12. // ONE FLAT LIST, rebuilt whole server-side on every click — the same proven-safe shape components/show.hl
  13. // uses for exactly the same Hybriel reasons (hybriel#86, hybriel#115/#116: a plain member function that
  14. // touches an hl:mpackdb-backed import must be `static` and must only ever be called server-side).
  15. parent './main.hl'
  16. import { appTitle } from '../lib/app.hl'
  17. import { userIdOfSession } from '../lib/users.hl'
  18. import { unwatchedToggleOf, unwatchedRowsOf } from '../lib/watches.hl'
  19. // ---- reactive members -----------------------------------------------------------------------
  20. session = null
  21. userId = userIdOfSession(&session)
  22. signedIn = userId != null
  23. // a plain copy of userId for `rows` (mission 047: session sync, see components/show.hl `me`)
  24. me = userId
  25. rows = signedIn ? unwatchedRowsOf(&me) : []
  26. hasRows = rows.length > 0
  27. noRows = !hasRows
  28. emptyText = signedIn ? 'No unwatched episodes.' : 'Sign in to see the shows you follow.'
  29. __title = 'Unwatched — ' + appTitle
  30. // HM49: component rules keep the existing selectors and shared theme variables.
  31. Style {
  32. unwatchedPage {
  33. display = 'block'
  34. }
  35. unwatchedRows {
  36. display = 'block'
  37. }
  38. unwatchedRow {
  39. display = 'grid'
  40. gridTemplateColumns = '2rem minmax(0, 1fr) auto'
  41. alignItems = 'center'
  42. gap = '0 .6rem'
  43. padding = '.5rem 0'
  44. @media {
  45. minWidth = '40rem'
  46. display = 'flex'
  47. }
  48. 'button.checkicon' {
  49. gridRow = 'span 2'
  50. }
  51. }
  52. unwatchedShow {
  53. fontWeight = '600'
  54. overflowWrap = 'anywhere'
  55. padding = '.7rem 0'
  56. margin = '-.7rem 0'
  57. @media {
  58. minWidth = '40rem'
  59. flex = 'none'
  60. }
  61. }
  62. unwatchedEpisode {
  63. gridColumn = '2 / 4'
  64. gridRow = '2'
  65. color = 'var(--color-text)'
  66. overflowWrap = 'anywhere'
  67. @media {
  68. minWidth = '40rem'
  69. flex = '1'
  70. }
  71. }
  72. unwatchedDate {
  73. gridRow = '1'
  74. gridColumn = '3'
  75. fontSize = '.85rem'
  76. color = 'var(--color-text-muted)'
  77. fontVariantNumeric = 'tabular-nums'
  78. @media {
  79. minWidth = '40rem'
  80. flex = 'none'
  81. }
  82. }
  83. }
  84. View {
  85. unwatchedPage {
  86. h1 { "Unwatched" }
  87. if (noRows) { p { class = "muted" emptyText } }
  88. if (hasRows) {
  89. unwatchedRows {
  90. for (row of rows) {
  91. unwatchedRow {
  92. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark episode watched"
  93. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  94. circle { cx = "12" cy = "12" r = "10" }
  95. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  96. }
  97. on click(e) { emit toggleEpisode(row.id) }
  98. }
  99. a { Style.unwatchedShow href = row.showHref row.showTitle }
  100. unwatchedEpisode { row.episodeLabel }
  101. unwatchedDate { row.release }
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. // The client only ever ASSIGNS the `rows` the server already rebuilt — never calls the tainted
  109. // local helper itself (components/show.hl's own `on toggleEpisode` follows the same shape, and
  110. // the same reason: `unwatchedRowsOf` touches mpackdb-backed imports, so it compiles to nothing on
  111. // the client, hybriel#115/#116).
  112. on toggleEpisode(episodeId) {
  113. if (!signedIn) { return null }
  114. r = emit server unwatchedToggle('' + episodeId)
  115. if (r == null || r.error != null) { return null }
  116. rows = r.rows
  117. }
  118. // ---- the face (the trailing `session` is always the server's: hybriel#16) ----
  119. on server unwatchedToggle(episodeId, session) {
  120. uid = userIdOfSession(&session)
  121. if (uid == null) { return { error = 'you are not signed in' } }
  122. return unwatchedToggleOf(episodeId, uid)
  123. }

Branches

Latest commits

  • 85cfb4ae|||PR records: AP61 day61, DP74 liveTracker
  • b1496147Merge branch 'ap61' into mainTracker
  • 2047955bMerge branch 'u12-gateports' into mainTracker
  • c8da40f3|||PR AP61: re-vendor Hybriel set day61 (source a05af47c, bin a11042e5)Tracker
  • 4e018678|||PR deploy.sh: gates use Tracker's ports 8716-8719 and LC_ALL=C; README: 2 backups keptTracker
  • 0b86324aMerge branch 'records-dp73' into mainTracker
  • 9ce5f59b|||PR records: DP73 live 613ae0e; deploy.sh keeps 2 backupsTracker
  • 613ae0ecMerge branch 'bs3' into mainTracker
  • 1383264b|||PR BS3: keep shared synchronous sorting fastTracker
  • 63e5ba1a|||PR BS3: guard boot imports and share resumable sort buffersTracker
  • 310613f1Merge branch 'records-dp72' into mainTracker
  • 6f7b61ba|||PR records: deploy-swap fix live, Kunibert findingsTracker
  • c41587d2Merge branch 'bs2' into mainTracker
  • 0dd538a6|||PR BS2: finish the boot index in slices so a booting instance keeps answeringTracker
  • 019d5cedMerge branch 'records-1110' into mainTracker
  • f88ae8b9|||PR records: day56 toggle live, reviewTracker
  • b6b3bb4dMerge branch 'ap56e' into mainTracker
  • 29a26da9|||PR AP56e: guard hidden show helpers during session syncTracker
  • 7c9ec236|||PR AP56e: re-vendor Hybriel set day56 (source 36ae83a8, bin c1f595a2)Tracker
  • 4b54f6f9Merge branch 'records-audit' into mainTracker