gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit03a8009703a80097Log: Anton GC A/Bmre03a80097/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

  • 03a80097Log: Anton GC A/Bmre
  • c7cdef62Log: Apollo STOP, workers pausedmre
  • d0c083fbLog: usage stopmre
  • c6d464e5Log: Apollo GO backlog, AP56 and BS1 startedmre
  • 1eb6f1a1Missions AP56, BS1mre
  • 4871f8adLog: AP52 live on day52, browser gate greenmre
  • d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
  • c4a60ef2Log: RT52 retest passed, AP52 startedmre
  • 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
  • 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
  • 2f391aa9Log: HM50 startedmre