@soffits/dsh-media-hub 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.0
4
+
5
+ - The recommender's picks moved from Discover to the Watching tab, under what you are watching, as *For you* (still switched by `presence.picks`). Each is the card of its kind (watch it, or download a book) under the reason it was picked. Discover keeps each source's trending lists and search.
6
+ - Fanqie's audiobooks no longer declare trending: the app's listening tab holds no audiobook works to list.
7
+ - The recommender protocol changed: `recommend` no longer takes `--source` and `--kind`; the hub passes the trending lists it already holds as candidates on stdin (`{ "candidates": [...] }`), so one run a day serves every category and the sources are asked nothing twice. Picks are kept as one dated copy per person and language and made in the background.
8
+
3
9
  ## 0.12.0
4
10
 
5
11
  - A show and a book look the same in the Library. Every item is one card: the same cover slot, a title with its type, one line of facts (a show's rating, status and progress; a book's author, format and size), tags, and the actions in the same place, with Delete under the … menu for books as it is for shows.
package/README.md CHANGED
@@ -30,7 +30,7 @@ The bundle adds two rows: `media-hub` (the page, shelves, rooms, media) and `med
30
30
 
31
31
  ## Use
32
32
 
33
- - **From the page**: open **Media** in the sidebar (the `label` setting renames it). Three tabs: **Watching** (the default) lists the rooms opened to others, with who is in them and the episode, with copying a room's link or closing it, and the shows someone started, to continue; **Library** manages the shows and starts or continues one; **Discover** searches: pick a source (*All sources*, every configured one, or *Link* to paste the address of a video or playlist), then one of that source's categories, then search. Before any search it shows what the sources put forward for that category (their rank lists and new arrivals, from a source's `trending` verb) and, when a `recommender` is set, *For you*: picks with the reason for each. Both are kept as dated copies and refreshed in the background about daily, so the page never waits on a site; *All sources* merges the picks and lists each source's boards under its name; Link has neither. The tab, source and category are in the page's URL (`?vs-tab=library`, `?vs-tab=discover&vs-source=<id>&vs-kind=<id>`), so a refresh and the back button keep them and a link can open a tab directly; the last source and category are remembered per browser.
33
+ - **From the page**: open **Media** in the sidebar (the `label` setting renames it). Three tabs: **Watching** (the default) lists the rooms opened to others, with who is in them and the episode, with copying a room's link or closing it, and the shows someone started, to continue; **Library** manages the shows and starts or continues one; **Discover** searches: pick a source (*All sources*, every configured one, or *Link* to paste the address of a video or playlist), then one of that source's categories, then search. Before any search it shows what the sources put forward for that category (their rank lists and new arrivals, from a source's `trending` verb) (Link has none). They are kept as dated copies and refreshed in the background about daily, so the page never waits on a site; *All sources* lists each source's boards under its name. Picks from a `recommender` show on the Watching tab. The tab, source and category are in the page's URL (`?vs-tab=library`, `?vs-tab=discover&vs-source=<id>&vs-kind=<id>`), so a refresh and the back button keep them and a link can open a tab directly; the last source and category are remembered per browser.
34
34
  - **Watching**: a card at the top for the show someone is in now, or the one you watched last, over its blurred cover: who is in the room, where it stands, a strip of its episodes (watched, now, on disk), and joining them, or continuing alone, or *Watch together* to open it to others. Optional parts, each off until switched on in `presence`: *So far*, a recap without spoilers kept with the show; *How was it?*, one tap that writes a rating into the watch log for a show finished or removed lately; and *Picks*, works a recommender extension suggests, each with its reason. Steps suggested for a show (written through the tool's `annotate`) show on the card when [@soffits/dsh-ui-actions](https://github.com/soffits/dsh-ui-actions) is installed.
35
35
  - **From the assistant**: `videosync` with `action: start` and `source: local` plus `path`, `source: link` plus `url` (and `quality`), or `source: <source id>` plus `id` (and `offline: true` to keep every episode), returns a link to send. `list` and `close` manage rooms, `library` lists the shows, `history` summarises the watch log (shows, episodes finished, where each viewer stopped, with whom, when).
36
36
 
package/dist/index.js CHANGED
@@ -10647,10 +10647,15 @@ async function commandExists(command, path = process.env.PATH ?? "") {
10647
10647
  }
10648
10648
  return false;
10649
10649
  }
10650
- function run(argv, { signal, timeoutMs, onStdoutLine, cwd, env } = {}) {
10650
+ function run(argv, { signal, timeoutMs, onStdoutLine, cwd, env, input } = {}) {
10651
10651
  return new Promise((resolve7, reject) => {
10652
10652
  const [command, ...args] = argv;
10653
- const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"], detached: true, cwd, env: { ...process.env, ...env } });
10653
+ const child = spawn(command, args, { stdio: [input === void 0 ? "ignore" : "pipe", "pipe", "pipe"], detached: true, cwd, env: { ...process.env, ...env } });
10654
+ if (input !== void 0) {
10655
+ child.stdin.on("error", () => {
10656
+ });
10657
+ child.stdin.end(input);
10658
+ }
10654
10659
  let stdout = "";
10655
10660
  let stderr = "";
10656
10661
  let pending = "";
@@ -11995,7 +12000,7 @@ var CookieRule = Schema.object({
11995
12000
  var DEFAULT_SOURCES = Object.freeze([
11996
12001
  {
11997
12002
  id: "fanqie",
11998
- kinds: [{ id: "drama", media: "video", trending: true }, { id: "audio", media: "audio", trending: true }, { id: "novel", media: "book", trending: true }],
12003
+ kinds: [{ id: "drama", media: "video", trending: true }, { id: "audio", media: "audio" }, { id: "novel", media: "book", trending: true }],
11999
12004
  filters: [],
12000
12005
  command: ["fanqie"],
12001
12006
  env: {}
@@ -13976,7 +13981,7 @@ var MAX_STEPS = 3;
13976
13981
  var STEP_ID = /^[a-z0-9][a-z0-9_-]{0,31}$/;
13977
13982
  var MAX_LABEL_CHARS = 120;
13978
13983
  var MAX_PROMPT_CHARS = 2e3;
13979
- var PICKS_LIMIT = 6;
13984
+ var PICKS_LIMIT = 8;
13980
13985
  var PICKS_TIMEOUT_MS = 6e4;
13981
13986
  var MAX_WHY_CHARS = 280;
13982
13987
  var badInput = (message) => Object.assign(new Error(message), { code: "invalid_arguments" });
@@ -14050,19 +14055,9 @@ function parsePicks(document2, hasSource, limit = PICKS_LIMIT) {
14050
14055
  }
14051
14056
  return out;
14052
14057
  }
14053
- async function recommend({ command, env = {}, cwd, hasSource }, { person, source, kind, language, limit = PICKS_LIMIT }) {
14054
- const argv = [
14055
- ...command,
14056
- "recommend",
14057
- "--json",
14058
- "--limit",
14059
- String(limit),
14060
- ...person.id ? ["--person", person.id] : [],
14061
- ...source ? ["--source", source] : [],
14062
- ...kind ? ["--kind", kind] : [],
14063
- ...language ? ["--language", language] : []
14064
- ];
14065
- const result = await run(argv, { timeoutMs: PICKS_TIMEOUT_MS, cwd, env });
14058
+ async function recommend({ command, env = {}, cwd, hasSource }, { person, language, limit = PICKS_LIMIT, candidates = [] }) {
14059
+ const argv = [...command, "recommend", "--json", "--limit", String(limit), ...person.id ? ["--person", person.id] : [], ...language ? ["--language", language] : []];
14060
+ const result = await run(argv, { timeoutMs: PICKS_TIMEOUT_MS, cwd, env, input: JSON.stringify({ candidates }) });
14066
14061
  if (result.code !== 0) throw new Error(`exit ${result.code}: ${result.stderr.trim().split("\n").pop() ?? ""}`);
14067
14062
  return parsePicks(JSON.parse(result.stdout), hasSource, limit);
14068
14063
  }
@@ -14778,9 +14773,9 @@ import { mkdir as mkdir10, readFile as readFile11, rename as rename8, writeFile
14778
14773
  import { dirname as dirname6 } from "node:path";
14779
14774
  var DAY_MS3 = 864e5;
14780
14775
  var HOUR_MS = 36e5;
14781
- function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOUR_MS, parallel = 2, now = Date.now }) {
14776
+ function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOUR_MS, parallel = 4, now = Date.now }) {
14782
14777
  const copies = /* @__PURE__ */ new Map();
14783
- const flying = /* @__PURE__ */ new Set();
14778
+ const flying = /* @__PURE__ */ new Map();
14784
14779
  const failedAt = /* @__PURE__ */ new Map();
14785
14780
  const waiting = [];
14786
14781
  let running = 0;
@@ -14808,7 +14803,10 @@ function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOU
14808
14803
  }
14809
14804
  }
14810
14805
  function ask(key, produce) {
14811
- flying.add(key);
14806
+ let settled;
14807
+ flying.set(key, new Promise((resolve7) => {
14808
+ settled = resolve7;
14809
+ }));
14812
14810
  waiting.push(async () => {
14813
14811
  try {
14814
14812
  copies.set(key, { at: now(), value: await produce() });
@@ -14821,11 +14819,23 @@ function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOU
14821
14819
  changed();
14822
14820
  } finally {
14823
14821
  flying.delete(key);
14822
+ settled();
14824
14823
  }
14825
14824
  });
14826
14825
  pump();
14827
14826
  }
14828
14827
  return {
14828
+ /**
14829
+ * Like `get`, but a missing copy is waited for (the first ask), for what another copy is made from; an old one still answers at once.
14830
+ * @param {string} key
14831
+ * @param {() => Promise<unknown>} produce
14832
+ */
14833
+ async ensure(key, produce) {
14834
+ const first = await this.get(key, produce);
14835
+ if (first.value !== null || !flying.has(key)) return first;
14836
+ await flying.get(key);
14837
+ return this.get(key, produce);
14838
+ },
14829
14839
  /**
14830
14840
  * @param {string} key
14831
14841
  * @param {() => Promise<unknown>} produce - the outside answer, asked only when the copy is missing or old
@@ -14842,7 +14852,6 @@ function createCopies({ file, changed, logger, maxAgeMs = DAY_MS3, retryMs = HOU
14842
14852
  }
14843
14853
 
14844
14854
  // src/discover.js
14845
- var DISCOVER_PICKS = 12;
14846
14855
  var notFound = (message) => Object.assign(new Error(message), { code: "not_found" });
14847
14856
  function createDiscover({ copies, sources, covers, recommender }) {
14848
14857
  async function sourcesFor(sourceId, kind, ability) {
@@ -14875,22 +14884,24 @@ function createDiscover({ copies, sources, covers, recommender }) {
14875
14884
  };
14876
14885
  },
14877
14886
  /**
14878
- * A person's picks for a source and category (merged under All sources), or without either (the Watching tab).
14887
+ * A person's picks (the Watching tab). The recommender is given what every source's trending copy holds, so one
14888
+ * run a day serves all categories and asks the sources nothing more.
14879
14889
  * @returns {Promise<{ picks: object[], loading: boolean }>}
14880
14890
  */
14881
- async picks(person, { source: sourceId = "", kind = "", language = "" } = {}) {
14891
+ async picks(person, { language = "" } = {}) {
14882
14892
  if (recommender.command.length === 0) return { picks: [], loading: false };
14883
- const narrowed = sourceId !== "";
14884
- const targets = narrowed ? await sourcesFor(sourceId, kind, () => true) : [null];
14885
- const copy = await Promise.all(targets.map((one) => copies.get(
14886
- `picks|${person.key}|${one?.id ?? "*"}|${narrowed ? kind : "*"}|${language}`,
14887
- () => recommend(recommender, { person, source: one?.id, kind: narrowed ? kind : void 0, language, limit: narrowed ? DISCOVER_PICKS : PICKS_LIMIT })
14888
- )));
14889
- const lists = copy.map((entry, index) => (entry.value ?? []).filter((pick5) => targets[index] === null || pick5.work.source === targets[index].id && (kind === "" || pick5.work.kind === kind)));
14890
- return {
14891
- picks: interleave(lists).map((pick5) => ({ ...pick5, work: withCovers(sources.get(pick5.work.source), pick5.work) })).slice(0, narrowed ? DISCOVER_PICKS : PICKS_LIMIT),
14892
- loading: copy.some((entry) => entry.loading)
14893
- };
14893
+ const copy = await copies.get(`picks|${person.key}|${language}`, async () => {
14894
+ const candidates = [];
14895
+ for (const one of sources.values()) {
14896
+ if (typeof one.trending !== "function" || !await one.available()) continue;
14897
+ for (const entry of one.kinds.filter((kind) => kind.trending === true)) {
14898
+ const trending = await copies.ensure(`trending|${one.id}|${entry.id}`, () => one.trending(entry.id));
14899
+ if (trending.value !== null) candidates.push({ source: one.id, kind: entry.id, lists: trending.value });
14900
+ }
14901
+ }
14902
+ return recommend(recommender, { person, language, candidates });
14903
+ });
14904
+ return { picks: (copy.value ?? []).map((pick5) => ({ ...pick5, work: withCovers(sources.get(pick5.work.source), pick5.work) })), loading: copy.loading };
14894
14905
  }
14895
14906
  };
14896
14907
  }
@@ -15381,7 +15392,7 @@ function createPersonRoutes({ hub, identity }) {
15381
15392
  path: `${PERSON_PATH}/picks`,
15382
15393
  methods: ["GET"],
15383
15394
  requestBody: "buffered",
15384
- fetch: handle((request, current, person) => current.picks(person, { source: param(request, "source"), kind: param(request, "kind"), language: param(request, "language") }))
15395
+ fetch: handle((request, current, person) => current.picks(person, { language: param(request, "language") }))
15385
15396
  },
15386
15397
  {
15387
15398
  path: `${PERSON_PATH}/steps`,
package/locale/en.json CHANGED
@@ -268,10 +268,8 @@
268
268
  "ratings.fine": "Fine",
269
269
  "ratings.not-for-me": "Not for me",
270
270
  "ratings.unfinished": "Didn't finish",
271
- "picks.heading": "Picks",
271
+ "picks.heading": "For you",
272
272
  "picks.hint": "Each with why it was picked",
273
- "feed.picks": "For you",
274
- "feed.picksHint": "Each with why it was picked",
275
273
  "feed.trending": "Trending",
276
274
  "feed.updated": "Updated {when}",
277
275
  "feed.all": "Show all",
package/locale/fr.json CHANGED
@@ -268,10 +268,8 @@
268
268
  "ratings.fine": "Bien",
269
269
  "ratings.not-for-me": "Pas pour moi",
270
270
  "ratings.unfinished": "Pas fini",
271
- "picks.heading": "Suggestions",
271
+ "picks.heading": "Pour vous",
272
272
  "picks.hint": "Chacune avec la raison du choix",
273
- "feed.picks": "Pour vous",
274
- "feed.picksHint": "Chaque suggestion avec sa raison",
275
273
  "feed.trending": "Tendances",
276
274
  "feed.updated": "Mis à jour {when}",
277
275
  "feed.all": "Tout afficher",
package/locale/zh.json CHANGED
@@ -268,10 +268,8 @@
268
268
  "ratings.fine": "还行",
269
269
  "ratings.not-for-me": "不太喜欢",
270
270
  "ratings.unfinished": "没看完",
271
- "picks.heading": "推荐",
271
+ "picks.heading": "为你推荐",
272
272
  "picks.hint": "每部都写了推荐理由",
273
- "feed.picks": "为你推荐",
274
- "feed.picksHint": "每个都带着推荐的理由",
275
273
  "feed.trending": "热门",
276
274
  "feed.updated": "{when}更新",
277
275
  "feed.all": "显示全部",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-media-hub",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "A media hub for DeepSeek Harness: search shows, novels, ebooks and papers across sources, watch together in sync, and download books in the format you want onto your own shelf.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/web/feed-view.js CHANGED
@@ -1,38 +1,36 @@
1
1
  /**
2
- * What Discover shows before a search, for the source and category picked:
3
- * "For you" (the recommender's picks, each with its reason) and one list per
4
- * board the source itself puts forward (its rank lists, new arrivals). Under
5
- * All sources the picks of every source are interleaved and each source's lists
6
- * follow, headed by the source. Both come from dated copies the plugin keeps
2
+ * What Discover shows before a search, for the source and category picked: one
3
+ * list per board the source itself puts forward (its rank lists, new arrivals).
4
+ * Under All sources each source's lists follow, headed by the source. Both come from dated copies the plugin keeps
7
5
  * (src/copies.js), so the page never waits on a site: while a copy is first
8
6
  * being made the area shows a loading state, and the plugin's change signal
9
- * brings the answer. A source that offers neither shows nothing.
7
+ * brings the answer. A source with no lists shows nothing.
10
8
  *
11
- * The works are the same cards as search results.
9
+ * The works are the same cards as search results; `PickedWork` is one under the
10
+ * reason it was picked (the Watching tab's picks).
12
11
  */
13
12
  import { BookCard } from './books-view.js'
14
13
  import { pick } from './i18n.js'
15
14
  import { Result } from './result-card.js'
16
- import { Changes, K, Spinner, api, asPerson, fillNodes, h, query, React } from './ui.js'
15
+ import { Changes, K, Spinner, api, fillNodes, h, query, React } from './ui.js'
17
16
 
18
17
  /** Works of a list shown before "Show all". */
19
18
  export const LIST_PREVIEW = 6
20
19
 
21
- /** What the plugin has for one source and category: its trending lists and this person's picks. */
22
- function useFeed(sourceId, kind, language) {
20
+ /** What the plugin has for one source and category: its trending lists. */
21
+ function useFeed(sourceId, kind) {
23
22
  const { discover } = React.useContext(Changes)
24
23
  const [feed, setFeed] = React.useState(null)
25
- const key = `${sourceId}|${kind}|${language}`
24
+ const key = `${sourceId}|${kind}`
26
25
  React.useEffect(() => {
27
26
  let live = true
28
27
  const asked = query({ source: sourceId, kind })
29
- Promise.all([api(`trending?${asked}`), asPerson(`picks?${asked}&${query({ language })}`)]).then(([trending, picks]) => {
28
+ api(`trending?${asked}`).then((trending) => {
30
29
  if (!live) return
31
30
  setFeed({
32
31
  key,
33
32
  trending: Array.isArray(trending.trending) ? trending.trending : [],
34
- picks: Array.isArray(picks.picks) ? picks.picks : [],
35
- loading: trending.loading === true || picks.loading === true,
33
+ loading: trending.loading === true,
36
34
  })
37
35
  })
38
36
  return () => { live = false }
@@ -53,27 +51,37 @@ function FeedSection({ id, title, hint, children }) {
53
51
  children)
54
52
  }
55
53
 
54
+ /** A work as the card of its kind: a book is downloaded in a format, anything else watched or listened to. */
55
+ export function WorkCard({ t, source, work, isBook, onOpen, onSaved, onFocus }) {
56
+ return isBook
57
+ ? h(BookCard, { t, source, result: work })
58
+ : h(Result, { t, source, result: work, onOpen, onSaved, onFocus })
59
+ }
60
+
61
+ /** One picked work under the reason it was picked. */
62
+ export function PickedWork({ t, source, work, why, onOpen, onSaved, onFocus }) {
63
+ if (source === undefined) return null
64
+ const book = source.kinds.find(kind => kind.id === work.kind)?.media === 'book'
65
+ return h('li', { className: 'vsync-feedPick' },
66
+ h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, why)),
67
+ h('ul', { className: 'vsync-rows' }, h(WorkCard, { t, source, work, isBook: book, onOpen, onSaved, onFocus })))
68
+ }
69
+
56
70
  export function DiscoverFeed({ t, sourceId, kind, sourceOf, isBook, onOpen, onSaved, onFocus }) {
57
- const feed = useFeed(sourceId, kind ?? '', t.language)
71
+ const feed = useFeed(sourceId, kind ?? '')
58
72
  const [expanded, setExpanded] = React.useState(() => new Set())
59
73
  if (feed === null) return h(Skeleton, { t })
60
- const { trending, picks, loading } = feed
61
- if (trending.length === 0 && picks.length === 0) return loading ? h(Skeleton, { t }) : null
74
+ const { trending, loading } = feed
75
+ if (trending.length === 0) return loading ? h(Skeleton, { t }) : null
62
76
 
63
77
  const card = (work) => {
64
78
  const from = sourceOf(work.source)
65
79
  if (from === undefined) return null
66
- return isBook(work.kind, from)
67
- ? h(BookCard, { key: `${from.id}:${work.id}`, t, source: from, result: work })
68
- : h(Result, { key: `${from.id}:${work.id}`, t, source: from, result: work, onOpen, onSaved, onFocus })
80
+ return h(WorkCard, { key: `${from.id}:${work.id}`, t, source: from, work, isBook: isBook(work.kind, from), onOpen, onSaved, onFocus })
69
81
  }
70
82
  const merged = sourceId === 'all'
71
83
 
72
84
  return h('div', { className: 'vsync-feed' },
73
- picks.length > 0 && h(FeedSection, { id: 'vsync-feed-picks', title: t('feed.picks'), hint: t('feed.picksHint') },
74
- h('ul', { className: 'vsync-rows vsync-results' }, picks.map(entry => h('li', { key: `${entry.work.source}:${entry.work.id}`, className: 'vsync-feedPick' },
75
- h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, entry.why)),
76
- h('ul', { className: 'vsync-rows' }, card(entry.work)))))),
77
85
  trending.flatMap(({ source: from, at, lists }) => lists.map((list) => {
78
86
  const id = `${from}:${list.id}`
79
87
  const name = pick(list.label, t.language).trim() || t('feed.trending')
package/web/panel.css CHANGED
@@ -346,19 +346,10 @@
346
346
  .vsync-ccRecap p{margin:0}
347
347
  .vsync-ccRecapHead{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:500;color:var(--dsw-alias-label-tertiary)}
348
348
  .vsync-ccRecapText{margin-top:4px!important;line-height:22px}
349
- .vsync-ccActions,.vsync-pickActions,.vsync-rateAnswers{display:flex;flex-wrap:wrap;gap:8px}
349
+ .vsync-ccActions,.vsync-rateAnswers{display:flex;flex-wrap:wrap;gap:8px}
350
350
  .vsync-rate{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;padding:12px 16px}
351
351
  .vsync-rateHead{display:flex;align-items:center;gap:12px;min-width:0}
352
352
  .vsync-rateText{min-width:0}
353
- .vsync-pickGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px}
354
- .vsync-pickCard{display:flex;gap:12px;padding:12px}
355
- .vsync-pickCover{flex:none;width:76px;height:114px;border-radius:8px;object-fit:cover}
356
- .vsync-pickBody{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}
357
- .vsync-pickOpen{flex:none;padding:0;border:0;background:none;cursor:pointer;border-radius:8px}
358
- .vsync-pickTitle{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:20px;text-align:start;overflow-wrap:anywhere;cursor:pointer}
359
- @media (hover:hover){.vsync-pickTitle:hover{text-decoration:underline}}
360
- .vsync-pickCard{transition:transform .15s ease}.vsync-pickCard:active{transform:scale(.99)}
361
- @media (prefers-reduced-motion:reduce){.vsync-pickCard{transition:none}}
362
353
  .vsync-pickWhy{display:flex;gap:6px;font-size:13px;line-height:19px;color:var(--dsw-alias-label-secondary)}
363
354
  .vsync-pickWhy .uk-icon{margin-top:2px}
364
355
  .vsync-feed{margin-top:8px}
@@ -366,12 +357,11 @@
366
357
  .vsync-feedPick{list-style:none;display:flex;flex-direction:column;gap:4px}
367
358
  .vsync-feedPick .vsync-pickWhy{margin:0 4px}
368
359
  .vsync-feedSection .vsync-more{display:flex;margin-top:0}
369
- .vsync-pickActions{margin-top:auto;padding-top:6px}
370
360
  @media (width<=640px){.vsync-cc{flex-direction:column;gap:14px}.vsync-ccPoster{width:112px;height:150px}.vsync-ccStrip .uk-segmentsLabelled{flex-wrap:wrap;row-gap:4px}.vsync-ccStrip .uk-segments{flex-basis:100%}}
371
361
  /* Interface chrome is not selectable and pictures don't drag; titles, recaps and reasons stay selectable. */
372
- .vsync-pageTabs,.vsync-ccActions,.vsync-rateAnswers,.vsync-pickActions,.vsync-ccLive,.vsync-sectionMeta,.vsync-sectionHead h2,.vsync-actions,.vsync-tabCount,.vsync-ccStrip,.vsync-rateHead .uk-tile{user-select:none;-webkit-user-select:none}
362
+ .vsync-pageTabs,.vsync-ccActions,.vsync-rateAnswers,.vsync-ccLive,.vsync-sectionMeta,.vsync-sectionHead h2,.vsync-actions,.vsync-tabCount,.vsync-ccStrip,.vsync-rateHead .uk-tile{user-select:none;-webkit-user-select:none}
373
363
  .vsync-page img{-webkit-user-drag:none;user-select:none;-webkit-user-select:none}
374
- .vsync-ccActions .uk-touch,.vsync-pickActions .uk-touch,.vsync-rateAnswers .uk-touch{font-size:13px}
364
+ .vsync-ccActions .uk-touch .uk-touch,.vsync-rateAnswers .uk-touch{font-size:13px}
375
365
  /* Points offer: an extra's price at the moment of the action */
376
366
  .vsync-pointsOffer{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:40;display:flex;align-items:center;gap:12px;max-width:min(560px,calc(100% - 32px));padding:10px 12px 10px 16px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-bg-base));box-shadow:var(--dsw-shadow-lv3)}
377
367
  .vsync-pointsText{flex:1;min-width:0;font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary)}
@@ -4,9 +4,8 @@
4
4
  * shows finished or removed lately (one tap writes a rating to the watch
5
5
  * log), and picks from the recommender extension with the reason for each.
6
6
  */
7
- import { Picture } from './details.js'
8
- import { FollowButton } from './follow.js'
9
- import { Btn, Changes, Icon, K, P, React, asPerson, asPersonPaying, displayName, fillNodes, h, query } from './ui.js'
7
+ import { PickedWork } from './feed-view.js'
8
+ import { Btn, Changes, K, P, React, asPerson, fillNodes, h, query } from './ui.js'
10
9
 
11
10
  /** The answers, in order, with the icon each one shows (DSH's own where it has one). */
12
11
  const ANSWERS = [
@@ -61,37 +60,11 @@ export function RatingsSection({ t, on, version }) {
61
60
  h('ul', { className: 'vsync-cards' }, pending.map(ask => h(RatingRow, { key: ask.show, t, ask, onAnswered: show => setPending(pending.filter(other => other.show !== show)) }))))
62
61
  }
63
62
 
64
- function PickCard({ t, pick, onOpen, onOpenWork }) {
65
- const { work, why } = pick
66
- const [busy, setBusy] = React.useState(false)
67
- const [error, setError] = React.useState(null)
68
- const meta = [work.kind && t(`kind.${work.kind}`) !== `kind.${work.kind}` ? t(`kind.${work.kind}`) : null, work.year, Number.isFinite(work.score) ? [work.scoreLabel, work.score].filter(Boolean).join(' ') : null].filter(Boolean)
69
- const together = async () => {
70
- setBusy(true)
71
- setError(null)
72
- const answer = await asPersonPaying('fetch', { source: work.source, id: work.id, watch: true, together: true, language: t.language, by: await displayName(t('guest')) })
73
- setBusy(false)
74
- if (answer.error) return setError(answer.error)
75
- if (answer.declined) return undefined
76
- return onOpen(answer.room.id)
77
- }
78
- return h(K.Surface, { as: 'li', className: 'vsync-pickCard' },
79
- h('button', { type: 'button', className: 'vsync-pickOpen', tabIndex: -1, 'aria-hidden': true, onClick: () => onOpenWork(work.source, work) },
80
- h(Picture, { pictures: [work.cover], className: 'vsync-pickCover', emptyClassName: 'vsync-pickCover vsync-ccPosterEmpty', icon: h(Icon.Film, { size: 22 }) })),
81
- h('div', { className: 'vsync-pickBody' },
82
- h('button', { type: 'button', className: 'vsync-pickTitle', onClick: () => onOpenWork(work.source, work) }, work.title),
83
- meta.length > 0 && h('p', { className: 'vsync-rowMeta' }, meta.join(' · ')),
84
- h('p', { className: 'vsync-pickWhy' }, h(K.Icon, { name: 'sparkles', size: 14, tone: 'violet' }), h('span', null, why)),
85
- h('div', { className: 'vsync-pickActions' },
86
- h(Btn, { disabled: busy, onClick: together, icon: h(P.IconUsersOutlineRegular, { size: 16 }) }, t('room.watchTogether')),
87
- h(FollowButton, { t, source: work.source, work, compact: true })),
88
- error && h('p', { className: 'vsync-error', role: 'alert' }, error)))
89
- }
90
-
91
- export function PicksSection({ t, on, onOpen, onOpenWork }) {
63
+ /** The picks, each the card of its kind (watch it, or download the book) under the reason it was picked. */
64
+ export function PicksSection({ t, on, sources, onOpen, onSaved, onOpenWork }) {
92
65
  const { discover } = React.useContext(Changes)
93
66
  const [picks] = usePersonList(on, `picks?${query({ language: t.language })}`, 'picks', discover)
94
- if (!picks || picks.length === 0) return null
67
+ if (!picks || picks.length === 0 || !sources) return null
95
68
  return h(Section, { id: 'vsync-picks', title: t('picks.heading'), hint: t('picks.hint') },
96
- h('ul', { className: 'vsync-cards vsync-pickGrid' }, picks.map(pick => h(PickCard, { key: `${pick.work.source}:${pick.work.id}`, t, pick, onOpen, onOpenWork }))))
69
+ h('ul', { className: 'vsync-rows vsync-results' }, picks.map(({ work, why }) => h(PickedWork, { key: `${work.source}:${work.id}`, t, source: sources.find(one => one.id === work.source), work, why, onOpen, onSaved, onFocus: other => onOpenWork(other.source ?? work.source, other) }))))
97
70
  }
@@ -81,7 +81,7 @@ export function WatchingTab({ t, rooms, library, onOpen, onChanged, onGo, onOpen
81
81
  h('h2', { id: 'vsync-news' }, t('follow.news')),
82
82
  h('ul', { className: 'vsync-cards' }, news.map(show => h(NewsRow, { key: show.path, t, show, onOpen, onChanged })))),
83
83
  h(RatingsSection, { t, on: presence.ratings === true, version: watchedVersion }),
84
- h(PicksSection, { t, on: presence.picks === true, onOpen, onOpenWork }),
84
+ h(PicksSection, { t, on: presence.picks === true, sources, onOpen, onSaved: onChanged, onOpenWork }),
85
85
  h(RoomsSection, { t, rooms, onOpen, onChanged }),
86
86
  others.length > 0 && h('section', { className: 'vsync-section', 'aria-labelledby': 'vsync-continue' },
87
87
  h('h2', { id: 'vsync-continue' }, t('watching.continue')),