refactor(plex): share showEpisodeKeys + honest empty Play-all

Extract the show->ordered-episode-keys flatten into one pure, unit-tested
helper (lib/plexQueue.ts) and use it at all three sites — the collection
Play-all (S4) and the show/season play-through pages in plexViews — so the
season-then-episode queue-order invariant lives in one place instead of three
hand-rolled copies. Behaviour-identical (the helper's ?? [] is a safe superset
of the collection site's previously non-null read).

Also: a show-collection whose shows expand to zero episodes had an enabled
Play-all that silently no-op'd — the same 'does nothing' state S4 removed for
the empty-queue case. Surface an honest info notice (plex.collection.playEmpty,
HU+EN) instead.
This commit is contained in:
2026-08-24 22:09:52 +02:00
parent 852b227ea2
commit 2e319be569
6 changed files with 53 additions and 3 deletions
+3 -2
View File
@@ -8,6 +8,7 @@ import { plexLang } from "../i18n";
import { pickRatingBadge } from "../lib/plexRating";
import { notifyActionError } from "../lib/actionErrors";
import { toggleWatchState } from "../lib/plexWatch";
import { showEpisodeKeys } from "../lib/plexQueue";
import {
ActionBtn,
BackBtn,
@@ -306,7 +307,7 @@ export function PlexShowView({
const show = d?.show;
const showLib = show?.library ?? undefined;
const allKeys = (d?.seasons ?? []).flatMap((se) => se.episodes.map((e) => e.id));
const allKeys = showEpisodeKeys(d);
const watched = show?.status === "watched";
const {
artBg,
@@ -568,7 +569,7 @@ export function PlexSeasonView({
// Play-through queue spans the WHOLE show (all seasons, in order) so a season's last episode rolls
// straight into the next season's first — the same cross-season order the show page already uses.
// seasonKeys stays only for the season-scoped "add to playlist" action.
const allKeys = (d?.seasons ?? []).flatMap((s) => s.episodes.map((e) => e.id));
const allKeys = showEpisodeKeys(d);
const watched = se?.status === "watched";
const { artBg, showCast, crossfade, toggleArtBg, toggleCast, toggleCrossfade } = useDetailPrefs();
useCrossfadeBackdrop(