From e0baa13ef95d4572e7e54c06f726bece266c6bae Mon Sep 17 00:00:00 2001 From: WonderAliceUwU Date: Fri, 30 Oct 2026 12:37:22 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20open=20downloads=20and=20?= =?UTF-8?q?upcoming=20titles=20with=20their=20jellyfin=20episodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Downloads rows now open the title details, and cards without a Jellyfin id are linked to the library by TMDb id. Also hide the empty profiles card on the Jellyfin setup, fall back to the setup when there are no users, and drop the back button when Jellyfin is unavailable. --- server/lib/services.ts | 38 ++++++++++++++++++- src/App.tsx | 85 +++++++++++++++++++++++++++++++++--------- src/index.css | 10 +++++ 3 files changed, 113 insertions(+), 20 deletions(-) diff --git a/server/lib/services.ts b/server/lib/services.ts index 582a4cf..36276f9 100644 --- a/server/lib/services.ts +++ b/server/lib/services.ts @@ -751,8 +751,23 @@ export async function getCalendar(config: AppConfig, start: Date, end: Date): Pr ? radarrResult.value.map((item) => mapRadarrCalendarEntry(item)) : [] + // Link each entry to its Jellyfin item, as search does, so the details can + // tell which episodes are already in the library. + const library = await getLibrarySnapshot(config).catch(() => null); + const libraryProviderIds = new Map(); + for (const libraryItem of library?.allItems ?? []) { + const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library'); + if (libraryCard?.tmdbId && libraryCard.providerId && (libraryCard.mediaType === 'movie' || libraryCard.mediaType === 'series')) { + libraryProviderIds.set(`${libraryCard.mediaType}:${libraryCard.tmdbId}`, libraryCard.providerId); + } + } + const allItems = [...sonarrItems, ...radarrItems] - .filter((item): item is CalendarEntry => Boolean(item)); + .filter((item): item is CalendarEntry => Boolean(item)) + .map((item) => { + const providerId = item.card.tmdbId ? libraryProviderIds.get(`${item.card.mediaType}:${item.card.tmdbId}`) : undefined; + return providerId ? { ...item, card: { ...item.card, providerId } } : item; + }); const backdropCache = new Map>(); const cards = await applyHighResBackdropsToCards(config, allItems.map(i => i.card), shouldUseHighResBackdropForCard, backdropCache, 'en'); @@ -968,11 +983,30 @@ async function removeSonarrSeriesIfEmpty( } } +async function withLibraryProviderId(config: AppConfig, card: MediaCard): Promise { + if (!card.tmdbId || (card.mediaType !== 'movie' && card.mediaType !== 'series' && card.mediaType !== 'tv')) { + return card; + } + + const library = await getLibrarySnapshot(config).catch(() => null); + const wantedType = card.mediaType === 'movie' ? 'movie' : 'series'; + for (const libraryItem of library?.allItems ?? []) { + const libraryCard = jellyfinToCard(libraryItem, libraryItem.Name || 'Library'); + if (libraryCard?.tmdbId === card.tmdbId && libraryCard.mediaType === wantedType) { + return { ...card, providerId: libraryCard.providerId }; + } + } + return card; +} + export async function getTitleDetails( config: AppConfig, request: TitleDetailsRequest ): Promise { - const { card, seasonId } = request; + const { seasonId } = request; + // Cards that don't come from Jellyfin (downloads, upcoming) are linked to + // their library item by TMDb id. + const card = request.card.providerId ? request.card : await withLibraryProviderId(config, request.card); const item = card.providerId ? await getJellyfinItemDetails(config, card.providerId) : null; const seriesItem = await resolveSeriesItem(config, card, item); const primaryItem = seriesItem || item; diff --git a/src/App.tsx b/src/App.tsx index d5e4abc..8e6a5b6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -594,7 +594,7 @@ function App() { /> ) : null} {route === 'calendar' && isRouteAvailable(route, connections) ? setSelectedCard({ card, originRect: originRect ?? null })} /> : null} - {route === 'downloads' && isRouteAvailable(route, connections) ? : null} + {route === 'downloads' && isRouteAvailable(route, connections) ? setSelectedCard({ card, originRect: originRect ?? null })} processingItems={processingItems} /> : null} {route === 'search' ? (
-
-

Profiles

-
- {props.users.map((user) => ( -
- - {user.label} -
- ))} + {props.users.length ? ( +
+

Profiles

+
+ {props.users.map((user) => ( +
+ + {user.label} +
+ ))} +
-
+ ) : null}
) @@ -1123,6 +1125,11 @@ function ProfileSelectionScreen(props: { ))} } + {!selectedUser && !props.users.length ? ( +
+

No Jellyfin users found. An administrator has to check the Jellyfin connection.

+
+ ) : null} {!selectedUser ?
)} -
+
{item.posterUrl || item.backdropUrl ? ( @@ -3409,6 +3418,43 @@ function DownloadsPage(props: { ) } +type DownloadCardSource = Pick & { id: string } + +// Opens the title behind a download; without a TMDb id there is nothing to open. +function downloadCardProps( + item: DownloadCardSource, + selectionMode: boolean, + onOpenCard: (card: MediaCard, originRect?: ModalOriginRect | null) => void +) { + if (!item.tmdbId || !item.mediaType || selectionMode) { + return { className: 'download-card' } + } + + const card: MediaCard = { + id: `download-${item.id}`, + tmdbId: item.tmdbId, + title: item.title, + subtitle: item.subtitle || '', + overview: '', + mediaType: item.mediaType === 'movie' ? 'movie' : 'series', + posterUrl: item.posterUrl || '', + backdropUrl: item.backdropUrl || item.posterUrl || '', + } + + return { + className: 'download-card is-openable', + role: 'button', + tabIndex: 0, + onClick: (event: React.MouseEvent) => onOpenCard(card, captureOriginRect(event.currentTarget)), + onKeyDown: (event: React.KeyboardEvent) => { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault() + onOpenCard(card, captureOriginRect(event.currentTarget)) + } + }, + } +} + function DownloadRow(props: { item: DownloadItem busy: boolean @@ -3416,6 +3462,7 @@ function DownloadRow(props: { selectionMode: boolean selected: boolean onToggleSelection: () => void + onOpenCard: (card: MediaCard, originRect?: ModalOriginRect | null) => void }) { const item = props.item const progressMeta = [item.size, item.speed, item.eta].filter(Boolean).join(' · ') @@ -3442,7 +3489,7 @@ function DownloadRow(props: { {props.selected ? '✓' : null} ) : null} -
+
{artwork ? ( @@ -3911,9 +3958,11 @@ function AdministrationScreen(props: { return (
- + {isJellyfinUnavailable(props.connections) ? : ( + + )}

Administration

Settings

@@ -4144,7 +4193,7 @@ function resolveEntryStage(config: AppConfig, options: ServiceOptionsResponse): return 'onboarding' } if (!options.jellyfinUsers.length) { - return 'profiles' + return 'onboarding' } if (!config.jellyfin.userId.trim()) { return 'profiles' diff --git a/src/index.css b/src/index.css index d2a8664..f8552dd 100644 --- a/src/index.css +++ b/src/index.css @@ -5940,3 +5940,13 @@ img { font-size: 1rem; } } + +.download-card.is-openable { + cursor: pointer; +} + +.download-card.is-openable:focus-visible { + outline: 2px solid rgba(255, 255, 255, 0.6); + outline-offset: 4px; + border-radius: 1rem; +}