gitoriaLog in with ident

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf14db671f14db671tracker#22-#25 (mission 058): episode air dates, season check = all episodes watched, movie watched check (+ /my/movies count), /genres/<genre> pages (movies + series, newest first, paginated); gate 238, tests/realdata-058.mjs, README + STATUSmref14db671/components/show.hl

24.6 KB

  1. // components/show.hl — `/shows/:slug` (tracker.worldapi.org#4): a show's own page. Creator's words:
  2. // "the poster on the left, right of it the title of the show, the genre pills, below the plot summary,
  3. // below that the artists just as normal links, separated with comma color red, genres are blue" (the
  4. // header) — "then all seasons in reverse order, latest on top, below them collapsable their episodes,
  5. // episodes first the round check icon, if the episode was watched by the user looking its solid, if
  6. // not its regular, then the episode number, then the title. the last season is not collapsed. click on
  7. // the check adds a watch. the season also has a check, if the season is checked or unchecked all its
  8. // episodes get checked or unchecked. artists link to /person/<artist-slug> the genre to /genre/<genre-slug>."
  9. //
  10. // THE ROWS ARE ONE FLAT LIST, not a nested for-loop over seasons > episodes: the vendored build may
  11. // still lack the fix for hybriel#86 (a nested for over a reassigned outer list keeps stale inner
  12. // cells) — a single-level `for (row of rows)` with a `kind` field, reassigned whole on every click,
  13. // is the same proven-safe shape components/main.hl's own header and ident's inbox.hl already use.
  14. // `rows` is rebuilt from scratch (seasons/episodes refetched by id, watch rows refetched) on every
  15. // toggle — cheap: a show has at most a few dozen episodes per season.
  16. //
  17. // Mission 047 (the creator, 2026-10-01): a caret at the season header's right edge (down = open, right = collapsed); episode
  18. // rows not indented; on a phone the title first, then the poster at full width, then genres/plot/cast; a Follow toggle
  19. // next to the title. SIGNED OUT the checks and Follow are visible too: a click opens the "sign in" modal (modal.hl, copied
  20. // from components.hybriel) and writes nothing.
  21. //
  22. // tracker.worldapi.org#17 (mission 057): the caret points DOWN while a season is closed and UP while it is open. Opening a
  23. // season shows SKELETON rows at once (min(episodes, 8), a CSS shimmer, styles.hl) and then its episodes from the face
  24. // `showSeasonEpisodes`, which takes NO session: a face with `session` makes hl:web re-mount the whole page on the server and
  25. // ship every session-derived member back as a `sync` (WebFramework.hl `inbound`) — that, not the episodes, was most of the
  26. // old 250–450 ms (real data). The watched state comes from `watchedEpisodes` (this show's watched episodes per season, rendered
  27. // with the page and re-synced after every watch face). Closing is client-only (no request). An ADULT show (only its
  28. // followers see it) keeps the session face `showRows`: the public face refuses adult seasons.
  29. //
  30. // tracker.worldapi.org#12: link icons under the title — the show on TMDB, IMDb, TheTVDB, TVmaze (a movie: TMDB + IMDb),
  31. // only for the ids it has (shows.hl externalLinksOf), each in a new tab.
  32. //
  33. // mission 058: #22 every episode row shows its air date (`release`, 'YYYY-MM-DD' like /my/unwatched; none → empty). #23 a
  34. // season's check is DERIVED: solid exactly when every one of its episodes is watched (a season without episodes: its own
  35. // season watch) — unchecking one episode turns the season off with the face's answer, checking it again turns it on; the
  36. // season click watches all when not all are watched, else unwatches all. #24 a MOVIE's page has its own watched check
  37. // (watch `targetType = 'movie'`, target = the title's id; face `showToggleMovie`), signed out → the sign-in modal.
  38. parent './main.hl'
  39. import Modal from './modal.hl'
  40. import { appTitle } from '../project.hl'
  41. import { userIdOfSession, loginHref } from '../users.hl'
  42. import { isFollowing, setFollowed } from '../follows.hl'
  43. import { showBySlug, showById, genreById, personById, seasonsOfShow, episodesOfSeason, seasonById, posterName, externalLinksOf } from '../shows.hl'
  44. import { watchesOfUser, isWatched, watchedSet, setWatched, setSeasonWatched, watchClassOf } from '../watches.hl'
  45. // ---- pure helpers ----------------------------------------------------------------------------
  46. // `static`, like calendar.hl's `soonOf` — a PLAIN instance member function that calls an
  47. // hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason, watchesOfUser, …) comes back null
  48. // when called from an `on server` face (confirmed by running the gate: "'buildRows' is not
  49. // callable — it holds null" at the face's call site, even though the SAME call works fine as a
  50. // member's own initializer at the top of this file). `static` is the proven-safe shape (calendar's
  51. // `soonOf`, called from `calLoad`/`calSettingsLoad`, an mpackdb-backed helper exactly like this one).
  52. static initialCollapsed = (seasons) => {
  53. let m = {}
  54. let i = 0
  55. while (i < seasons.length) {
  56. if (i > 0) { m[seasons[i].id] = true }
  57. i = i + 1
  58. }
  59. return m
  60. }
  61. static genreRowsOf = (show) => {
  62. let out = []
  63. for (gid of show.genres) {
  64. let g = genreById(gid)
  65. if (g != null) { out.push({ id = g.id name = g.name href = '/genres/' + g.urlSegment }) }
  66. }
  67. return out
  68. }
  69. static castRowsOf = (show) => {
  70. let out = []
  71. for (c of show.cast) {
  72. let p = personById(c.person)
  73. if (p != null) { out.push({ name = c.actor href = '/person/' + p.urlSegment }) }
  74. }
  75. return out
  76. }
  77. // a View attribute must be a literal, a member or a field path — never an inline expression — so
  78. // every ternary (watched -> icon class, collapsed -> row class) is resolved HERE, once, into a
  79. // plain field the View just reads (row.watchClass, row.rowClass); `watchClassOf` itself lives in
  80. // watches.hl (shared with /unwatched and /schedule, "reuse, don't copy")
  81. // #22: an episode's air date as the lists show it ('YYYY-MM-DD'), '' when it has none
  82. static airDateOf = (e) => { return e.release != null && hlTypeName(e.release) == 'String' ? e.release : '' }
  83. // #23: a season is watched when ALL its episodes are (by the ids it lists); one without episodes keeps its own season watch
  84. static seasonAllWatched = (s, watched) => {
  85. if (s.episodes.length == 0) { return watched['season:' + s.id] == true }
  86. for (eid of s.episodes) { if (watched['episode:' + eid] != true) { return false } }
  87. return true
  88. }
  89. static buildRows = (show, uid, collapsed) => {
  90. let watched = watchedSet(uid != null ? watchesOfUser(uid) : [])
  91. let out = []
  92. for (s of seasonsOfShow(show)) {
  93. let isCollapsed = collapsed[s.id] == true
  94. let label = s.title != null && s.title != '' ? s.title : 'Season ' + s.seasonNumber
  95. let seasonWatched = seasonAllWatched(s, watched)
  96. out.push({ kind = 'season' isSeason = true isEpisode = false isSkeleton = false id = s.id skeletonCount = s.episodes.length < 8 ? s.episodes.length : 8 label = label episodeCountText = s.episodes.length == 1 ? '1 episode' : s.episodes.length + ' episodes' watched = seasonWatched watchClass = watchClassOf(seasonWatched) collapsed = isCollapsed rowClass = isCollapsed ? 'collapsed' : 'expanded' })
  97. if (!isCollapsed) {
  98. for (e of episodesOfSeason(s)) {
  99. let epWatched = watched['episode:' + e.id] == true
  100. out.push({ kind = 'episode' isSeason = false isEpisode = true isSkeleton = false id = e.id seasonId = s.id episodeNumber = e.episodeNumber title = e.title != null ? e.title : '' airDate = airDateOf(e) watched = epWatched watchClass = watchClassOf(epWatched) })
  101. }
  102. }
  103. }
  104. return out
  105. }
  106. // what the client marks the rows of a season it opens with (tracker#17) — only this show's, never the user's whole watch
  107. // list (every member is shipped to the browser). Per season with a watched episode: `{ all, except }` — `all` = most of
  108. // it is watched, then `except` holds the UNwatched ids, else the watched ones (a fully watched 142-episode season is
  109. // `{ all = true except = {} }`, not 142 ids). No entry = nothing watched.
  110. static watchedEpisodesOf = (show, uid) => {
  111. let m = {}
  112. if (uid == null) { return m }
  113. let watched = watchedSet(watchesOfUser(uid))
  114. for (s of seasonsOfShow(show)) {
  115. let yes = {}
  116. let no = {}
  117. let n = 0
  118. for (eid of s.episodes) {
  119. if (watched['episode:' + eid] == true) { yes[eid] = true n = n + 1 } else { no[eid] = true }
  120. }
  121. if (n > 0) { m[s.id] = n * 2 > s.episodes.length ? { all = true except = no } : { all = false except = yes } }
  122. }
  123. return m
  124. }
  125. // is this episode watched, by that per-season shape (client-side, pure)
  126. static watchedIn = (entry, episodeId) => {
  127. if (entry == null) { return false }
  128. let listed = entry.except[episodeId] == true
  129. return entry.all ? !listed : listed
  130. }
  131. // ---- the rows as the CLIENT changes them (tracker#17) — pure: no import is reached, so they run in the browser ----------
  132. // (`watchClassOf` is an import of the mpackdb-backed watches.hl, so `filledRows` writes its two classes itself)
  133. static seasonRowAs = (row, isCollapsed) => {
  134. return { kind = 'season' isSeason = true isEpisode = false isSkeleton = false id = row.id skeletonCount = row.skeletonCount label = row.label episodeCountText = row.episodeCountText watched = row.watched watchClass = row.watchClass collapsed = isCollapsed rowClass = isCollapsed ? 'collapsed' : 'expanded' }
  135. }
  136. // the season opened: its caret up at once, `skeletonCount` placeholder rows under it
  137. static openingRows = (rows, seasonId) => {
  138. let out = []
  139. for (row of rows) {
  140. if (row.isSeason && row.id == seasonId) {
  141. out.push(seasonRowAs(row, false))
  142. let i = 0
  143. while (i < row.skeletonCount) {
  144. out.push({ kind = 'skeleton' isSeason = false isEpisode = false isSkeleton = true id = seasonId + '-skeleton-' + i seasonId = seasonId })
  145. i = i + 1
  146. }
  147. } else { out.push(row) }
  148. }
  149. return out
  150. }
  151. // the season closed: its episode (and skeleton) rows gone, caret down
  152. static closedRows = (rows, seasonId) => {
  153. let out = []
  154. for (row of rows) {
  155. if (row.isSeason && row.id == seasonId) { out.push(seasonRowAs(row, true)) }
  156. else if (!row.isSeason && row.seasonId == seasonId) { }
  157. else { out.push(row) }
  158. }
  159. return out
  160. }
  161. // the episodes arrived: they replace the season's skeleton rows. No skeleton of it left (closed meanwhile, or a watch face
  162. // already rebuilt every row) → the rows stay as they are (no double rows)
  163. static filledRows = (rows, seasonId, episodes, watched) => {
  164. let out = []
  165. let done = false
  166. for (row of rows) {
  167. if (row.isSkeleton && row.seasonId == seasonId) {
  168. if (!done) {
  169. for (e of episodes) {
  170. let w = watchedIn(watched[seasonId], e.id)
  171. out.push({ kind = 'episode' isSeason = false isEpisode = true isSkeleton = false id = e.id seasonId = seasonId episodeNumber = e.episodeNumber title = e.title airDate = e.airDate watched = w watchClass = w ? 'checkicon solid' : 'checkicon regular' })
  172. }
  173. done = true
  174. }
  175. } else { out.push(row) }
  176. }
  177. return out
  178. }
  179. // a LOCAL static like buildRows (an imported mpackdb helper called straight from a member's initializer came back false
  180. // after a client-side navigation to the page — the gate's follow check)
  181. static followingOf = (show, uid) => { return uid != null && isFollowing(uid, show.id) }
  182. // #24: has this user watched this movie (a watch `movie:<title id>`)?
  183. static movieWatchedOf = (show, uid) => { return uid != null && isWatched(watchesOfUser(uid), 'movie', show.id) }
  184. // mission 056: an ADULT title's page (TMDB's flag `adult == true`, mission 054) is "Not found" for everyone who does not
  185. // follow it (signed out too); a follower sees it as before. Unknown (`null`) is not hidden here — only in the lists.
  186. // With hybriel ≥ 73267707 (#121/#122) `showRow`/`found` are server sites re-derived after every session face with the page's
  187. // slug, so an Unfollow on the page hides it at once (the gate proves it; the old build left the page up until a reload).
  188. // Mission 054's try (`found = … && !adultHiddenFor(showRow, me)`, `collapsed`/`rows` from `found`) broke the checks.
  189. static adultHiddenFor = (show, uid) => { return show.adult == true && !followingOf(show, uid) }
  190. // the page's show — null when there is none OR it is hidden for this user: every member is shipped to the browser, so the
  191. // row of a hidden title must never be one
  192. static visibleShow = (slug, uid) => {
  193. let s = showBySlug(slug)
  194. return s != null && adultHiddenFor(s, uid) ? null : s
  195. }
  196. // the initial open/closed seasons from the SLUG alone (not from `showRow`, which reads the session — see `collapsed`)
  197. static initialCollapsedOf = (slug) => {
  198. let s = showBySlug(slug)
  199. return s != null ? initialCollapsed(seasonsOfShow(s)) : {}
  200. }
  201. // ---- reactive members -----------------------------------------------------------------------
  202. slug = null
  203. session = null
  204. userId = userIdOfSession(session)
  205. signedIn = userId != null
  206. // SESSION SYNC (mission 047; since hybriel #121/#122, mission 056): a face taking `session` answers with a `sync` of every
  207. // member derived from session that reaches an import (here `showRow`, `found`, `following`, `rows`, …), re-derived on the
  208. // server with the page's route params but the MOUNT's other state — so client state (`collapsed`) must never derive from
  209. // them. `me` stays the plain copy mission 047 introduced.
  210. me = userId
  211. showRow = visibleShow(slug, me)
  212. found = showRow != null
  213. notFound = showRow == null
  214. // the Follow toggle: "Follow" = the inverted button (accent border), "Following" = the filled one
  215. following = found ? followingOf(showRow, me) : false
  216. followClass = following ? 'follow' : 'follow inverted'
  217. followText = following ? 'Following' : 'Follow'
  218. signInHref = loginHref
  219. // #24: a movie's watched check (same icon/classes as the episodes); the classes written out, not `watchClassOf` (an import of
  220. // the mpackdb-backed watches.hl cannot run in the browser when the member is re-derived there)
  221. isMovie = found && showRow.type == 'movie'
  222. movieWatched = isMovie ? movieWatchedOf(showRow, me) : false
  223. movieWatchClass = movieWatched ? 'checkicon solid' : 'checkicon regular'
  224. movieWatchText = movieWatched ? 'Watched' : 'Not watched'
  225. signInText = isMovie ? 'You need to sign in to follow movies and mark them watched.' : 'You need to sign in to follow shows and mark episodes.'
  226. title = found ? showRow.title : ''
  227. summary = found && showRow.summary != null ? showRow.summary : ''
  228. poster = found ? posterName(showRow) : null
  229. hasPoster = poster != null
  230. posterUrl = hasPoster ? '/posters/' + poster : ''
  231. genreRows = found ? genreRowsOf(showRow) : []
  232. hasGenres = genreRows.length > 0
  233. castRows = found ? castRowsOf(showRow) : []
  234. hasCast = castRows.length > 0
  235. linkRows = found ? externalLinksOf(showRow) : []
  236. hasLinks = linkRows.length > 0
  237. // NOT from `showRow`/`found`: they read the session (via `me`), so a member derived from them is re-derived on the server
  238. // after every session face with the MOUNT's state — `collapsed` (client state) would snap back to the initial seasons (mission
  239. // 056: the 2nd episode click in a re-opened season did nothing). The season ids of a hidden page are no secret.
  240. collapsed = initialCollapsedOf(slug)
  241. rows = found ? buildRows(showRow, me, collapsed) : []
  242. hasRows = rows.length > 0
  243. watchedEpisodes = found ? watchedEpisodesOf(showRow, me) : {}
  244. // an adult page (followers only) opens its seasons through the session face `showRows`
  245. adultShow = found && showRow.adult == true
  246. __title = found ? title + ' — ' + appTitle : appTitle
  247. View {
  248. showPage {
  249. if (notFound) {
  250. article { class = "main"
  251. h1 { "Not found" }
  252. p { "This show doesn't exist." }
  253. }
  254. }
  255. if (found) {
  256. showHeader {
  257. showPoster { if (hasPoster) { img { src = posterUrl alt = title } } }
  258. showMeta {
  259. showTitle {
  260. h1 { title }
  261. button { id = "follow" type = "button" class = followClass followText on click(e) { emit toggleFollow(e) } }
  262. }
  263. if (isMovie) {
  264. movieWatch {
  265. button { id = "moviewatch" type = "button" class = movieWatchClass "aria-label" = "mark movie watched"
  266. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  267. circle { cx = "12" cy = "12" r = "10" }
  268. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  269. }
  270. on click(e) { emit toggleMovie(e) }
  271. }
  272. movieWatchLabel { movieWatchText }
  273. }
  274. }
  275. if (hasLinks) {
  276. showLinks {
  277. for (l of linkRows) { a { class = "extlink" href = l.href target = "_blank" rel = "noopener" title = l.title "aria-label" = l.title "data-site" = l.site l.label } }
  278. }
  279. }
  280. if (hasGenres) {
  281. showGenres {
  282. for (g of genreRows) { a { class = "genre-pill" href = g.href g.name } }
  283. }
  284. }
  285. showSummary { summary }
  286. if (hasCast) {
  287. showCast {
  288. for (c of castRows) { a { class = "artist-link" href = c.href c.name } }
  289. }
  290. }
  291. }
  292. }
  293. if (hasRows) {
  294. showSeasons {
  295. for (row of rows) {
  296. if (row.isSeason) {
  297. seasonRow { class = row.rowClass
  298. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark season watched"
  299. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  300. circle { cx = "12" cy = "12" r = "10" }
  301. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  302. }
  303. on click(e) { emit toggleSeason(row.id) }
  304. }
  305. button { type = "button" class = "season-toggle" value = row.id
  306. seasonLabel { row.label }
  307. seasonCount { row.episodeCountText }
  308. seasonCaret { "aria-hidden" = "true"
  309. svg { viewBox = "0 0 24 24" width = "20" height = "20"
  310. path { d = "M6 9 L12 15 L18 9" }
  311. }
  312. }
  313. on click(e) { emit toggleCollapse(row.id) }
  314. }
  315. }
  316. }
  317. if (row.isEpisode) {
  318. episodeRow {
  319. button { type = "button" class = row.watchClass value = row.id "aria-label" = "mark episode watched"
  320. svg { viewBox = "0 0 24 24" width = "22" height = "22" "aria-hidden" = "true"
  321. circle { cx = "12" cy = "12" r = "10" }
  322. path { d = "M7 12.5 L10.5 16 L17 8.5" }
  323. }
  324. on click(e) { emit toggleEpisode(row.id) }
  325. }
  326. episodeNumber { row.episodeNumber }
  327. episodeTitle { row.title }
  328. episodeDate { row.airDate }
  329. }
  330. }
  331. if (row.isSkeleton) {
  332. skeletonRow { "aria-hidden" = "true"
  333. skeletonCheck { }
  334. skeletonNumber { }
  335. skeletonTitle { }
  336. }
  337. }
  338. }
  339. }
  340. }
  341. Modal { id = "signin" title = "Sign in"
  342. p { signInText }
  343. footer {
  344. button { type = "button" value = "close" "Close" }
  345. a { id = "signin-link" class = "button" href = signInHref "Sign in with ident" }
  346. }
  347. }
  348. }
  349. }
  350. }
  351. // Every rebuild of `rows` happens SERVER-SIDE, never by calling `buildRows` from a client handler:
  352. // a member function whose body reaches an hl:mpackdb-backed import (seasonsOfShow, episodesOfSeason,
  353. // watchesOfUser, …) compiles to nothing on the client (no case ever assigns it — a genuine Hybriel
  354. // gap, filed under `issues`) even though the client bundle still calls it, so `this.buildRows(...)`
  355. // throws "not a function" in the browser. The client here only ever ASSIGNS the `rows` the server
  356. // already built (`rows = r.rows`) — never calls a tainted local helper itself. `slug` goes along so
  357. // the face can refetch the show without depending on implicit access to a sibling member.
  358. //
  359. // tracker#17: opening shows the skeleton rows BEFORE the request; the answer replaces them unless the season was closed
  360. // meanwhile (then nothing). An error closes the season again. Closing never asks the server.
  361. on toggleCollapse(seasonId) {
  362. let m = collapsed
  363. if (collapsed[seasonId] != true) {
  364. m[seasonId] = true
  365. collapsed = m
  366. rows = closedRows(rows, seasonId)
  367. return null
  368. }
  369. m[seasonId] = false
  370. collapsed = m
  371. rows = openingRows(rows, seasonId)
  372. if (adultShow) {
  373. let a = emit server showRows(slug, collapsed)
  374. if (collapsed[seasonId] == true) { return null }
  375. if (a == null || a.error != null) { m[seasonId] = true collapsed = m rows = closedRows(rows, seasonId) return null }
  376. rows = a.rows
  377. return null
  378. }
  379. let r = emit server showSeasonEpisodes('' + seasonId)
  380. if (collapsed[seasonId] == true) { return null }
  381. if (r == null || r.error != null) { m[seasonId] = true collapsed = m rows = closedRows(rows, seasonId) return null }
  382. rows = filledRows(rows, seasonId, r.episodes, watchedEpisodes)
  383. }
  384. // signed out: the modal, nothing is sent
  385. on toggleEpisode(episodeId) {
  386. if (!signedIn) { document.getElementById('signin').showModal() return null }
  387. let r = emit server showToggleEpisode(slug, '' + episodeId, collapsed)
  388. if (r == null || r.error != null) { return null }
  389. rows = r.rows
  390. }
  391. on toggleSeason(seasonId) {
  392. if (!signedIn) { document.getElementById('signin').showModal() return null }
  393. let r = emit server showToggleSeason(slug, '' + seasonId, collapsed)
  394. if (r == null || r.error != null) { return null }
  395. rows = r.rows
  396. }
  397. // #24: the movie's own check — signed out the modal, nothing sent
  398. on toggleMovie(e) {
  399. if (!signedIn) { document.getElementById('signin').showModal() return null }
  400. let r = emit server showToggleMovie(slug)
  401. if (r == null || r.error != null) { return null }
  402. movieWatched = r.watched
  403. movieWatchClass = r.watched ? 'checkicon solid' : 'checkicon regular'
  404. movieWatchText = r.watched ? 'Watched' : 'Not watched'
  405. }
  406. on toggleFollow(e) {
  407. if (!signedIn) { document.getElementById('signin').showModal() return null }
  408. let r = emit server showToggleFollow(slug)
  409. if (r == null || r.error != null) { return null }
  410. following = r.following
  411. followClass = r.following ? 'follow' : 'follow inverted'
  412. followText = r.following ? 'Following' : 'Follow'
  413. }
  414. // ---- the faces (the trailing `session` is always the server's: hybriel#16) ----
  415. // every row for these open/closed seasons — only an ADULT show's page still uses it (its followers; tracker#17)
  416. on server showRows(slug, collapsed, session) {
  417. let show = showBySlug(slug)
  418. let uid = userIdOfSession(session)
  419. if (show == null || adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  420. return { ok = true rows = buildRows(show, uid, collapsed) }
  421. }
  422. // tracker#17: one season's episodes, in order — public data, so NO `session` (no page re-mount, no sync: the fast path).
  423. // Refuses a season of an adult title (those pages use showRows above).
  424. on server showSeasonEpisodes(seasonId) {
  425. if (seasonId == null || hlTypeName(seasonId) != 'String') { return { error = 'no such season' } }
  426. let season = seasonById(seasonId)
  427. if (season == null) { return { error = 'no such season' } }
  428. let show = showById(season.show)
  429. if (show == null || show.adult == true) { return { error = 'no such season' } }
  430. let out = []
  431. for (e of episodesOfSeason(season)) { out.push({ id = e.id episodeNumber = e.episodeNumber title = e.title != null ? e.title : '' airDate = airDateOf(e) }) }
  432. return { ok = true episodes = out }
  433. }
  434. on server showToggleEpisode(slug, episodeId, collapsed, session) {
  435. let show = showBySlug(slug)
  436. if (show == null) { return { error = 'no such show' } }
  437. let uid = userIdOfSession(session)
  438. if (uid == null) { return { error = 'you are not signed in' } }
  439. if (adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  440. let rows = watchesOfUser(uid)
  441. let watched = isWatched(rows, 'episode', episodeId) == false
  442. let ok = setWatched(uid, 'episode', episodeId, rows, watched)
  443. if (!ok) { return { error = 'could not save the watch' } }
  444. return { ok = true rows = buildRows(show, uid, collapsed) }
  445. }
  446. on server showToggleSeason(slug, seasonId, collapsed, session) {
  447. let show = showBySlug(slug)
  448. if (show == null) { return { error = 'no such show' } }
  449. let uid = userIdOfSession(session)
  450. if (uid == null) { return { error = 'you are not signed in' } }
  451. if (adultHiddenFor(show, uid)) { return { error = 'no such show' } }
  452. let season = seasonById(seasonId)
  453. if (season == null) { return { error = 'no such season' } }
  454. let rows = watchesOfUser(uid)
  455. // #23: not all episodes watched → watch them all; all watched → unwatch them all
  456. let watched = !seasonAllWatched(season, watchedSet(rows))
  457. let ok = setSeasonWatched(uid, seasonId, season.episodes, rows, watched)
  458. if (!ok) { return { error = 'could not save the watch' } }
  459. return { ok = true rows = buildRows(show, uid, collapsed) }
  460. }
  461. // #24: a movie's watched check (only a movie: a series is watched by its episodes)
  462. on server showToggleMovie(slug, session) {
  463. let show = showBySlug(slug)
  464. if (show == null || show.type != 'movie') { return { error = 'no such movie' } }
  465. let uid = userIdOfSession(session)
  466. if (uid == null) { return { error = 'you are not signed in' } }
  467. if (adultHiddenFor(show, uid)) { return { error = 'no such movie' } }
  468. let rows = watchesOfUser(uid)
  469. let watched = isWatched(rows, 'movie', show.id) == false
  470. if (!setWatched(uid, 'movie', show.id, rows, watched)) { return { error = 'could not save the watch' } }
  471. return { ok = true watched = watched }
  472. }
  473. on server showToggleFollow(slug, session) {
  474. let show = showBySlug(slug)
  475. if (show == null) { return { error = 'no such show' } }
  476. let uid = userIdOfSession(session)
  477. if (uid == null) { return { error = 'you are not signed in' } }
  478. let follow = isFollowing(uid, show.id) == false
  479. if (!setFollowed(uid, show.id, follow)) { return { error = 'could not save the follow' } }
  480. return { ok = true following = follow }
  481. }

Branches

Latest commits

  • f14db671tracker#22-#25 (mission 058): episode air dates, season check = all episodes watched, movie watched check (+ /my/movies count), /genres/<genre> pages (movies + series, newest first, paginated); gate 238, tests/realdata-058.mjs, README + STATUSmre
  • 1704ec45tracker#17 (mission 057): season caret down/up, skeleton rows while a season loads, sessionless showSeasonEpisodes face (no page re-mount), client-only close; gate 214, tests/realdata-057.mjs, README + STATUSmre
  • f2fe3e36mission 056: README + STATUS (merge, fixes, Hybriel 8590df63, real-data check), tests/realdata-056.mjs, tools/check-public-slugs.hlmre
  • f40c250emission 056: re-vendor hybriel master 8590df63 (#121, #122); an adult title's page is Not found for non-followers; gate: leave the page before stopping the servermre
  • 2b7fdd6cmission 056: signed-out header one row on phones ("Log in", nowrap), backfill skips adult titles' posters, gate checksmre
  • 2c53d5efMerge branch 't16-person' (tracker#16 person pages) into main; filmography shows only public titles (054 adult flag), gate race fix (backfill start line)mre
  • c171227emission 054: hide adult/unknown titles from the public lists and the search; in-app adult-flag backfill (TMDB details + poster per title, resumes), gate + real-data proofmre
  • 139fafd8tracker#16: short bio (4 lines, click = all), real-data check script, README + STATUSmre
  • 93be9476tracker#16: person pages /person/<slug> with the filmography fetched from TMDB on the first visit (step by step), gatemre
  • 47a3cae6STATUS: mission 053 merge commit idsmre
  • dcc5eecaMerge branch 't14-search'mre
  • 03edc783Merge branch 't15-tvmaze'mre
  • 71b46345tracker#15: numbering check by date or title, placeholder titles in other languages, docs + real-data proofmre
  • 6bb2daf1tracker#13: homepage (tiles, intro, latest movies/shows), /shows, /movies/page/N, /my/movies; lists cached in memorymre
  • b8bd1157tracker#14: README + STATUS (search, real-data numbers, gate, merge notes)mre
  • 65c694a8tracker#14: search — header magnifier, /search/<text> (in-memory word-prefix index over titles + people), Fetch from web (TMDB search/multi, ours left out), Add = import via syncShow; gate +25 checks, real-data scriptmre
  • 34f2c15btracker#15: TVmaze merge in the sync (gaps only: new episodes/seasons, empty titles/air dates; numbering check), fake TVmaze episodes + gatemre
  • cbdc4ea7tracker#12: link icons TMDB/IMDb/TVDB/TVmaze; sync fills missing ids (TVmaze lookup); movies fetched via /movie/mre
  • b105bcd8tracker#11: Hybriel master ff51cf46 (checks no longer vanish), mobile-first styles, carets, follow button, sign-in modal, inverted check, orange castmre
  • 31b758aatracker#10: installable app (manifest, service worker, offline shell), own icon + faviconmre