feat(downloads): a bare link is titled once, a missing picture shows a glyph

A job with no name yet is titled by its short link, as the link itself;
the channel line no longer falls back to the ref and the link line does
not repeat it. No picture at all draws a film (or note) glyph instead of
an empty box.
This commit is contained in:
2026-09-27 07:12:51 +02:00
parent f48f16830e
commit 098b8dbe43
3 changed files with 104 additions and 21 deletions
+22 -1
View File
@@ -2,6 +2,27 @@ import type { DownloadJob } from "../lib/api";
// A download job's display title (a user rename wins over the extracted asset title), shared by the
// row, the admin list and the library player. Its own module so downloadRow exports only components.
// With no name yet — a link queued before its details arrive, or one that failed first — it is the
// link itself, shortened the way the row shows a link, never the raw ref (a URL, or a bare video id).
export function jobTitle(job: DownloadJob): string {
return job.display_name || job.asset?.title || job.source_ref;
return (
job.display_name ||
job.asset?.title ||
(job.source_url ? displayUrl(job.source_url) : job.source_ref)
);
}
/** The job has a name of its own (a rename or an extracted title), not the link standing in for one. */
export function hasOwnTitle(job: DownloadJob): boolean {
return !!(job.display_name || job.asset?.title);
}
// Compact display of a URL: drop the protocol + trailing slash so "youtube.com/watch?v=…" fits.
export function displayUrl(url: string): string {
try {
const u = new URL(url);
return (u.host + u.pathname + u.search).replace(/\/$/, "");
} catch {
return url;
}
}