Merge remote-tracking branch 'origin/main' into fix/255-provider-reorder
# Conflicts: # web/src/icons.ts
This commit is contained in:
+96
-67
@@ -414,7 +414,7 @@ function main() {
|
||||
library.open();
|
||||
await movieDetail.open(
|
||||
route.movieId,
|
||||
must<HTMLElement>("#nav-library"),
|
||||
must<HTMLElement>("#wordmark"),
|
||||
must<HTMLElement>("#library"),
|
||||
{
|
||||
kind: "library",
|
||||
@@ -439,7 +439,7 @@ function main() {
|
||||
library.open();
|
||||
await seriesDetail.open(
|
||||
route.seriesId,
|
||||
must<HTMLElement>("#nav-library"),
|
||||
must<HTMLElement>("#wordmark"),
|
||||
must<HTMLElement>("#library"),
|
||||
{
|
||||
kind: "library",
|
||||
@@ -485,7 +485,7 @@ function main() {
|
||||
library.open();
|
||||
await seriesDetail.open(
|
||||
seriesId,
|
||||
must<HTMLElement>("#nav-library"),
|
||||
must<HTMLElement>("#wordmark"),
|
||||
must<HTMLElement>("#library"),
|
||||
{ kind: "library" },
|
||||
);
|
||||
@@ -496,7 +496,7 @@ function main() {
|
||||
sub,
|
||||
seriesId,
|
||||
target,
|
||||
origin: must<HTMLElement>("#nav-library"),
|
||||
origin: must<HTMLElement>("#wordmark"),
|
||||
returnTo: must<HTMLElement>("#series"),
|
||||
parentRoute: { kind: "series", seriesId },
|
||||
});
|
||||
@@ -701,11 +701,13 @@ function searchMain(
|
||||
refs.groups.library.rows.append(librarySeriesRow(series, roots, openSeries));
|
||||
}
|
||||
}
|
||||
if (response.tmdb.length > 0) {
|
||||
// a TMDB hit already in the library group above never repeats here
|
||||
const tmdbHits = response.tmdb.filter((hit) => !inLibrary.has(hit.tmdb_id));
|
||||
if (tmdbHits.length > 0) {
|
||||
refs.groups.tmdb.section.hidden = false;
|
||||
refs.groups.tmdb.count.textContent = String(response.tmdb.length);
|
||||
for (const hit of response.tmdb) {
|
||||
refs.groups.tmdb.rows.append(tmdbRow(hit, inLibrary.has(hit.tmdb_id), fetchRoots));
|
||||
refs.groups.tmdb.count.textContent = String(tmdbHits.length);
|
||||
for (const hit of tmdbHits) {
|
||||
refs.groups.tmdb.rows.append(tmdbRow(hit, fetchRoots));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -835,8 +837,23 @@ function chip(text: string, extra?: (chip: HTMLSpanElement) => void): HTMLSpanEl
|
||||
return span;
|
||||
}
|
||||
|
||||
/** §4.2 state ramp on a media-state chip; the word carries, colour accelerates. */
|
||||
/**
|
||||
* §4.2 state ramp on a media-state chip. `available` is a drawn check glyph —
|
||||
* a shape, not only a hue, so it still reads greyscale — with the word kept
|
||||
* as the chip's aria-label; every other state keeps the word on the chip.
|
||||
*/
|
||||
function mediaStateChip(state: string, wanted: boolean): HTMLSpanElement {
|
||||
if (state === "available") {
|
||||
return chip("", (span) => {
|
||||
span.replaceChildren(icon("check"));
|
||||
// a bare span's aria-label is not reliably exposed; role="img" is what
|
||||
// makes the word reachable once the glyph replaced it
|
||||
span.setAttribute("role", "img");
|
||||
span.setAttribute("aria-label", state);
|
||||
span.dataset.movieState = state;
|
||||
span.dataset.wanted = String(wanted);
|
||||
});
|
||||
}
|
||||
return chip(state, (span) => {
|
||||
span.dataset.movieState = state;
|
||||
span.dataset.wanted = String(wanted);
|
||||
@@ -1749,7 +1766,7 @@ function libraryRow(
|
||||
}
|
||||
chips.append(trailerChip("movie", movie.tmdb_id));
|
||||
const affordance = document.createElement("span");
|
||||
affordance.className = "row-add readout";
|
||||
affordance.className = "row-add control readout";
|
||||
affordance.textContent = "open";
|
||||
chips.append(affordance);
|
||||
body.append(rowTitle(movie.title, movie.year), chips);
|
||||
@@ -1782,7 +1799,7 @@ function librarySeriesRow(
|
||||
}
|
||||
chips.append(trailerChip("tv", series.tmdb_id));
|
||||
const affordance = document.createElement("span");
|
||||
affordance.className = "row-add readout";
|
||||
affordance.className = "row-add control readout";
|
||||
affordance.textContent = "episodes";
|
||||
chips.append(affordance);
|
||||
body.append(rowTitle(series.title, series.year), chips);
|
||||
@@ -1795,30 +1812,18 @@ function librarySeriesRow(
|
||||
}
|
||||
|
||||
/** A TMDB hit of either kind — the row opens the add flow (§9.2). */
|
||||
function tmdbRow(
|
||||
hit: TmdbMovie | TmdbSeries,
|
||||
inLibrary: boolean,
|
||||
fetchRoots: () => Promise<Root[]>,
|
||||
): HTMLLIElement {
|
||||
function tmdbRow(hit: TmdbMovie | TmdbSeries, fetchRoots: () => Promise<Root[]>): HTMLLIElement {
|
||||
const { item, row, body, chips } = richRow();
|
||||
chips.append(chip(hit.original_language));
|
||||
if (inLibrary) {
|
||||
chips.append(
|
||||
chip("in library", (span) => {
|
||||
span.dataset.verdict = "eligible";
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
const add = document.createElement("span");
|
||||
add.className = "row-add readout";
|
||||
add.textContent = "add";
|
||||
chips.append(add);
|
||||
}
|
||||
const rating = ratingChip(hit.vote_average, hit.vote_count);
|
||||
if (rating !== null) {
|
||||
chips.append(rating);
|
||||
}
|
||||
chips.append(trailerChip(hit.kind === "series" ? "tv" : "movie", hit.tmdb_id));
|
||||
const add = document.createElement("span");
|
||||
add.className = "row-add control readout";
|
||||
add.textContent = "add";
|
||||
chips.append(add);
|
||||
body.append(rowTitle(hit.title, hit.year), chips);
|
||||
if (hit.overview) {
|
||||
const overview = document.createElement("span");
|
||||
@@ -1829,13 +1834,6 @@ function tmdbRow(
|
||||
row.append(rowPoster(hit.poster_path, hit.title), body);
|
||||
item.append(row);
|
||||
|
||||
if (inLibrary) {
|
||||
// aria-disabled, not disabled: a dead button would also kill the
|
||||
// trailer chip's clicks, and that chip stays live on every row
|
||||
row.setAttribute("aria-disabled", "true");
|
||||
return item;
|
||||
}
|
||||
|
||||
row.setAttribute("aria-expanded", "false");
|
||||
row.addEventListener("click", () => {
|
||||
const open = item.querySelector(".add-panel");
|
||||
@@ -2079,6 +2077,20 @@ function wireCollapsedToggle(bucket: CollapsedBucketDom) {
|
||||
// icon() and armedDeleteIcon() live in icons.ts, shared with the settings
|
||||
// rows (#231); the §9.6 painters below stay here as their only consumer.
|
||||
|
||||
/**
|
||||
* Invisible spacer that reserves a delete control's slot (#254). It is the
|
||||
* delete control's own box, hidden — a hand-sized guess drifts as soon as the
|
||||
* icon control's padding changes, and an 8px drift is the misalignment this
|
||||
* was meant to remove.
|
||||
*/
|
||||
function placeholderSlot(): HTMLSpanElement {
|
||||
const slot = document.createElement("span");
|
||||
slot.className = "control control-quiet control-icon slot-icon";
|
||||
slot.setAttribute("aria-hidden", "true");
|
||||
slot.append(icon("trash"));
|
||||
return slot;
|
||||
}
|
||||
|
||||
/** §9.6 provider marks, drawn and shipped inline — never a remote image. */
|
||||
function providerMark(name: "tmdb" | "tvdb" | "imdb" | "rt"): SVGSVGElement {
|
||||
const svg = document.createElementNS(SVG_NS, "svg");
|
||||
@@ -3360,7 +3372,6 @@ function libraryMain(
|
||||
): LibraryView {
|
||||
const view = must<HTMLElement>("#library");
|
||||
const deck = must<HTMLElement>("#deck");
|
||||
const nav = must<HTMLButtonElement>("#nav-library");
|
||||
const summary = must<HTMLElement>("#library-summary");
|
||||
const toggle = must<HTMLButtonElement>("#library-toggle");
|
||||
const status = must<HTMLElement>("#library-status");
|
||||
@@ -3505,25 +3516,14 @@ function libraryMain(
|
||||
}
|
||||
deck.hidden = true;
|
||||
view.hidden = false;
|
||||
nav.setAttribute("aria-pressed", "true");
|
||||
void load();
|
||||
}
|
||||
|
||||
function hide() {
|
||||
view.hidden = true;
|
||||
nav.setAttribute("aria-pressed", "false");
|
||||
sequence += 1;
|
||||
}
|
||||
|
||||
// §9.7: the library is the homepage — the bottom layer. There is nothing
|
||||
// beneath it, so the nav control never toggles off and Esc has no handler.
|
||||
nav.addEventListener("click", () => {
|
||||
if (view.hidden) {
|
||||
navigate({ kind: "library" });
|
||||
open();
|
||||
}
|
||||
});
|
||||
|
||||
toggle.addEventListener("click", () => {
|
||||
showAll = !showAll;
|
||||
render();
|
||||
@@ -3541,12 +3541,7 @@ function seriesRow(
|
||||
roots: Root[],
|
||||
open: (id: number, origin: HTMLElement) => void,
|
||||
): HTMLLIElement {
|
||||
const item = document.createElement("li");
|
||||
const row = document.createElement("button");
|
||||
row.type = "button";
|
||||
row.className = "row row-tmdb";
|
||||
const chips = document.createElement("span");
|
||||
chips.className = "row-chips";
|
||||
const { item, row, body, chips } = richRow();
|
||||
const root = roots.find((candidate) => candidate.id === series.root_id);
|
||||
chips.append(chip(root ? root.audience : `root ${series.root_id}`));
|
||||
if (series.wanted_episodes > 0) {
|
||||
@@ -3568,10 +3563,11 @@ function seriesRow(
|
||||
}),
|
||||
);
|
||||
const affordance = document.createElement("span");
|
||||
affordance.className = "row-add readout";
|
||||
affordance.className = "row-add control readout";
|
||||
affordance.textContent = "episodes";
|
||||
chips.append(affordance);
|
||||
row.append(rowTitle(series.title, series.year), chips);
|
||||
body.append(rowTitle(series.title, series.year), chips);
|
||||
row.append(rowPoster(series.poster_path, series.title), body);
|
||||
row.addEventListener("click", () => {
|
||||
open(series.id, row);
|
||||
});
|
||||
@@ -4453,10 +4449,29 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
disclose.focus();
|
||||
});
|
||||
|
||||
// season 0 never counts toward tracking or totals (§4.1, §4.2); say so
|
||||
// the whole line expands the season — the chevron stays the accessible
|
||||
// control and this is a second way in; clicks on real controls opt out
|
||||
line.addEventListener("click", (event) => {
|
||||
if (event.target instanceof Element && event.target.closest("button")) {
|
||||
return;
|
||||
}
|
||||
disclose.click();
|
||||
});
|
||||
|
||||
// season 0 never counts toward tracking or totals (§4.1, §4.2); say so.
|
||||
// Both forms are rendered and CSS picks one: narrow viewports show the
|
||||
// SxxEyy-style tag the rest of the app already uses, so the row's controls
|
||||
// keep their place instead of wrapping under it.
|
||||
const name = document.createElement("span");
|
||||
name.className = "season-name";
|
||||
name.textContent = season.number === 0 ? "specials · s00" : `season ${PAD_TWO(season.number)}`;
|
||||
const nameLong = document.createElement("span");
|
||||
nameLong.className = "season-name-long";
|
||||
nameLong.textContent =
|
||||
season.number === 0 ? "specials · s00" : `season ${PAD_TWO(season.number)}`;
|
||||
const nameShort = document.createElement("span");
|
||||
nameShort.className = "season-name-short";
|
||||
nameShort.textContent = seasonTag(season.number);
|
||||
name.append(nameLong, nameShort);
|
||||
|
||||
const track = document.createElement("button");
|
||||
track.type = "button";
|
||||
@@ -4483,8 +4498,13 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
});
|
||||
});
|
||||
|
||||
const space = document.createElement("span");
|
||||
space.className = "season-space";
|
||||
// everything that describes the season shares one shrinkable box; the
|
||||
// controls sit outside it, so a long flag chip wraps within the head
|
||||
// rather than pushing search and delete onto a line of their own.
|
||||
const head = document.createElement("span");
|
||||
head.className = "season-head";
|
||||
const actions = document.createElement("span");
|
||||
actions.className = "season-actions";
|
||||
|
||||
const deckBtn = document.createElement("button");
|
||||
deckBtn.type = "button";
|
||||
@@ -4514,7 +4534,7 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
});
|
||||
});
|
||||
|
||||
line.append(disclose, name, track, seasonCountsChip(season));
|
||||
head.append(name, track, seasonCountsChip(season));
|
||||
// #227: the season the operator's report is about read `0/10` with
|
||||
// nothing saying a pack had been grabbed, downloaded in full and thrown
|
||||
// out at import. The counts chip beside this one is exactly the number
|
||||
@@ -4524,7 +4544,7 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
const kind = blacklistClass(failure.reason);
|
||||
const when = failure.failed_at === null ? "" : ` ${formatSweepAge(failure.failed_at)}`;
|
||||
const told = `a pack for this season downloaded in full and failed at import${when} — ${failure.release} · ${blacklistAdvice(failure.reason)}`;
|
||||
line.append(
|
||||
head.append(
|
||||
chip(`import failed · ${blacklistReasonLabel(failure.reason)}`, (span) => {
|
||||
span.dataset.flag = "import-failed";
|
||||
span.dataset.blacklist = kind;
|
||||
@@ -4536,17 +4556,17 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
// The season-level twin of the episode flag above: gone upstream while
|
||||
// files under it remained.
|
||||
if (season.vanished) {
|
||||
line.append(
|
||||
head.append(
|
||||
chip("vanished", (span) => {
|
||||
span.dataset.flag = "vanished";
|
||||
}),
|
||||
);
|
||||
}
|
||||
line.append(space, deckBtn);
|
||||
// #174: files go, episodes stop being wanted, the season stays listed.
|
||||
// Only offered with files on disk — intent alone is the tracked toggle.
|
||||
let clear: HTMLButtonElement | null = null;
|
||||
if (season.episodes.some((episode) => filesByEpisode.has(episode.id))) {
|
||||
const clear = armedDeleteIcon(
|
||||
clear = armedDeleteIcon(
|
||||
`remove ${season.number === 0 ? "specials" : `season ${PAD_TWO(season.number)}`} files from disk and stop wanting its episodes — the season stays listed`,
|
||||
() => {
|
||||
const currentId = seriesId;
|
||||
@@ -4555,7 +4575,9 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
}
|
||||
void removeSeasonFiles(currentId, season.number).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
clear.disabled = false;
|
||||
if (clear) {
|
||||
clear.disabled = false;
|
||||
}
|
||||
setStatus(`remove failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
@@ -4566,8 +4588,10 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
});
|
||||
},
|
||||
);
|
||||
line.append(clear);
|
||||
}
|
||||
// rows without a delete still reserve its slot, so search keeps its column
|
||||
actions.append(deckBtn, clear ?? placeholderSlot());
|
||||
line.append(disclose, head, actions);
|
||||
item.append(line);
|
||||
|
||||
const episodes = document.createElement("ul");
|
||||
@@ -4652,7 +4676,7 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
const note = document.createElement("span");
|
||||
note.className = "readout dim ep-unaired";
|
||||
note.textContent = "unaired";
|
||||
actions.append(note);
|
||||
actions.append(note, placeholderSlot());
|
||||
} else {
|
||||
const want = document.createElement("button");
|
||||
want.type = "button";
|
||||
@@ -4699,6 +4723,9 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
});
|
||||
});
|
||||
actions.append(deckBtn);
|
||||
// no delete on a wantable episode, but its slot is still reserved so
|
||||
// search sits in the same column as on an on-disk row
|
||||
actions.append(placeholderSlot());
|
||||
}
|
||||
|
||||
item.append(tag, name, air, chips, actions);
|
||||
@@ -4999,6 +5026,7 @@ function queuesMain(
|
||||
const view = must<HTMLElement>("#queues");
|
||||
const deck = must<HTMLElement>("#deck");
|
||||
const nav = must<HTMLButtonElement>("#nav-queues");
|
||||
nav.prepend(icon("warning"));
|
||||
const badge = must<HTMLElement>("#queues-count");
|
||||
const summary = must<HTMLElement>("#queues-summary");
|
||||
const status = must<HTMLElement>("#queues-status");
|
||||
@@ -5044,6 +5072,7 @@ function queuesMain(
|
||||
}
|
||||
|
||||
function paintBadge(total: number) {
|
||||
nav.hidden = total === 0;
|
||||
badge.hidden = total === 0;
|
||||
badge.textContent = total === 0 ? "" : String(total);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user