fix: image loading

This commit is contained in:
WonderAliceUwU committed 2026-07-08 01:09:01 +02:00
1 parent 55956bc52d
commit 1550fcd065
3 files changed
+408 -101

No files matched your search

+51 -4
View File
@@ -443,7 +443,8 @@ export async function getTitleDetails(
const primaryItem = seriesItem || item;
const isSeries = card.mediaType === 'series' || card.mediaType === 'tv' || seriesItem?.Type === 'Series' || item?.Type === 'Episode';
const detailMediaType: 'movie' | 'tv' = primaryItem?.Type === 'Movie' || card.mediaType === 'movie' ? 'movie' : 'tv';
const tmdbId = Number(primaryItem?.ProviderIds?.Tmdb) || card.tmdbId;
const tvdbId = Number(primaryItem?.ProviderIds?.Tvdb) || undefined;
const tmdbId = Number(primaryItem?.ProviderIds?.Tmdb) || card.tmdbId || await resolveTmdbSeriesIdByTvdbId(config, tvdbId);
const originalLanguage = card.originalLanguage;
const [backdropUrl, logoUrl] = await Promise.all([
tmdbId ? getTmdbHighResBackdrop(config, tmdbId, detailMediaType, null, originalLanguage) : Promise.resolve(''),
@@ -792,6 +793,24 @@ async function getTmdbSeriesSummary(config: AppConfig, tmdbId: number): Promise<
);
}
async function resolveTmdbSeriesIdByTvdbId(config: AppConfig, tvdbId?: number): Promise<number | undefined> {
if (!tvdbId) {
return undefined;
}
try {
const response = await tmdbFetch(
config,
`/find/${encodeURIComponent(String(tvdbId))}?external_source=tvdb_id`
);
const firstMatch = asArray(response?.tv_results)[0];
const id = Number(asRecord(firstMatch).id || 0);
return id || undefined;
} catch {
return undefined;
}
}
async function getJellyfinSeriesSeasons(config: AppConfig, seriesId: string): Promise<SeriesSeasonDescriptor[]> {
try {
const seasons = await jellyfinFetch<JellyfinItem[]>(
@@ -871,7 +890,7 @@ async function getTmdbSeasonEpisodes(
): Promise<TmdbEpisodeRecord[]> {
const response = await tmdbFetch(
config,
`/tv/${tmdbId}/season/${seasonNumber}?language=${encodeURIComponent(config.preferences.language)}`
`/tv/${tmdbId}/season/${seasonNumber}`
);
return asArray(response?.episodes)
@@ -1259,7 +1278,7 @@ function mapJellyfinEpisode(episode: JellyfinItem): TitleDetailsEpisode {
typeof episode.ParentIndexNumber === 'number' ? `Season ${episode.ParentIndexNumber}` : '',
typeof episode.IndexNumber === 'number' ? `Episode ${episode.IndexNumber}` : ''
].filter(Boolean).join(', '),
imageUrl: buildJellyfinAssetUrl(String(episode.Id), 'Primary', 960, imageTag),
imageUrl: imageTag ? buildJellyfinAssetUrl(String(episode.Id), 'Primary', 960, imageTag) : '',
seasonNumber: episode.ParentIndexNumber,
episodeNumber: episode.IndexNumber,
runtimeMinutes: episode.RunTimeTicks ? Math.max(1, Math.round(episode.RunTimeTicks / 600000000)) : undefined,
@@ -1505,7 +1524,7 @@ async function getLibrarySnapshot(config: AppConfig): Promise<{
.map((item) => [String(item.Id), Number(item.ProviderIds?.Tmdb) || undefined] as const)
);
const continueWatching = [...resume, ...nextUp]
const continueWatching = dedupeContinueWatchingItems([...resume, ...nextUp])
.slice(0, 12)
.map((item) => jellyfinToCard(item, item.SeriesName || item.Name || 'Continue watching', tmdbIdByItemId))
.filter(Boolean) as MediaCard[];
@@ -1527,6 +1546,34 @@ async function getLibrarySnapshot(config: AppConfig): Promise<{
};
}
function dedupeContinueWatchingItems(items: JellyfinItem[]): JellyfinItem[] {
const seen = new Set<string>();
const deduped: JellyfinItem[] = [];
for (const item of items) {
const key = getContinueWatchingKey(item);
if (seen.has(key)) {
continue;
}
seen.add(key);
deduped.push(item);
}
return deduped;
}
function getContinueWatchingKey(item: JellyfinItem): string {
if (item.Type === 'Episode') {
const seriesKey = item.SeriesId || item.SeriesName || item.Id || 'series';
const seasonKey = typeof item.ParentIndexNumber === 'number' ? item.ParentIndexNumber : 'x';
const episodeKey = typeof item.IndexNumber === 'number' ? item.IndexNumber : item.Id || 'x';
return `episode:${seriesKey}:${seasonKey}:${episodeKey}`;
}
return `${item.Type || 'item'}:${item.Id || item.Name || 'unknown'}`;
}
async function buildHubSections(
config: AppConfig,
library: Awaited<ReturnType<typeof getLibrarySnapshot>>,
+144 -57
View File
@@ -26,6 +26,7 @@ import {
type AuthState = 'loading' | 'setup' | 'login' | 'app'
type EntryStage = 'onboarding' | 'profiles' | 'dashboard'
type EntryTransitionState = 'idle' | 'forward-enter' | 'forward-exit' | 'back-enter' | 'back-exit'
const MAX_CACHED_HUB_PAGES = 3
type ModalOriginRect = { left: number; top: number; width: number; height: number }
type SelectedCardState = { card: MediaCard; originRect: ModalOriginRect | null }
@@ -73,6 +74,29 @@ function App() {
const [hubLoading, setHubLoading] = useState(false)
const [selectedCard, setSelectedCard] = useState<SelectedCardState | null>(null)
const [downloadDeleteId, setDownloadDeleteId] = useState('')
const [entryTransitionState, setEntryTransitionState] = useState<EntryTransitionState>('idle')
async function transitionEntryStage(nextStage: EntryStage) {
if (nextStage === entryStage) {
return
}
const isProfileDashboardSwitch
= (entryStage === 'profiles' && nextStage === 'dashboard')
|| (entryStage === 'dashboard' && nextStage === 'profiles')
if (!isProfileDashboardSwitch) {
setEntryStage(nextStage)
return
}
setEntryTransitionState(entryStage === 'profiles' ? 'forward-exit' : 'back-exit')
await wait(240)
setEntryStage(nextStage)
setEntryTransitionState(nextStage === 'dashboard' ? 'forward-enter' : 'back-enter')
await wait(520)
setEntryTransitionState('idle')
}
async function refreshBaseData() {
const [settings, serviceOptions, dashboard] = await Promise.all([
@@ -198,7 +222,9 @@ function App() {
}
await refreshBaseData()
setPassword('')
setNotice(authState === 'setup' ? 'Instance initialized.' : 'Signed in.')
if (authState === 'setup') {
setNotice('Instance initialized.')
}
setAuthState('app')
} catch (authError) {
setError(authError instanceof Error ? authError.message : 'Authentication failed.')
@@ -217,7 +243,7 @@ function App() {
apiKey: config.jellyfin.apiKey,
})
setOptions((current) => ({ ...current, jellyfinUsers: response.jellyfinUsers }))
setEntryStage(response.jellyfinUsers.length ? 'profiles' : 'onboarding')
await transitionEntryStage(response.jellyfinUsers.length ? 'profiles' : 'onboarding')
setNotice(response.jellyfinUsers.length ? 'Jellyfin users loaded.' : 'No Jellyfin users found.')
} catch (loadError) {
setError(loadError instanceof Error ? loadError.message : 'Failed to load Jellyfin users.')
@@ -241,8 +267,7 @@ function App() {
const response = await api.saveSettings(nextConfig)
setConfig(response.config)
await refreshBaseData()
setEntryStage('dashboard')
setNotice('Profile selected.')
await transitionEntryStage('dashboard')
setRoute('home')
} catch (selectError) {
setError(selectError instanceof Error ? selectError.message : 'Failed to select Jellyfin profile.')
@@ -353,15 +378,17 @@ function App() {
if (entryStage === 'profiles') {
return (
<ProfileSelectionScreen
busy={busy}
currentUserId={config.jellyfin.userId}
error={error}
notice={notice}
onBackToOnboarding={() => setEntryStage('onboarding')}
onSelectUser={handleSelectJellyfinUser}
users={options.jellyfinUsers}
/>
<div className={getEntryTransitionClassName(entryTransitionState)}>
<ProfileSelectionScreen
busy={busy}
currentUserId={config.jellyfin.userId}
error={error}
notice={notice}
onBackToOnboarding={() => void transitionEntryStage('onboarding')}
onSelectUser={handleSelectJellyfinUser}
users={options.jellyfinUsers}
/>
</div>
)
}
@@ -370,12 +397,12 @@ function App() {
const currentHub = route !== 'downloads' && route !== 'settings' ? hubPages[route as HubPageResponse['page']] : undefined
return (
<div className="omniarr-app">
<div className={`omniarr-app ${getEntryTransitionClassName(entryTransitionState)}`}>
<Sidebar
busy={busy}
connections={connections}
currentUser={currentJellyfinUser}
onExitProfile={() => setEntryStage('profiles')}
onExitProfile={() => void transitionEntryStage('profiles')}
route={route}
setRoute={setRoute}
/>
@@ -429,6 +456,14 @@ function App() {
)
}
function getEntryTransitionClassName(state: EntryTransitionState) {
return state === 'idle' ? 'entry-stage-shell' : `entry-stage-shell is-${state}`
}
function wait(ms: number) {
return new Promise((resolve) => window.setTimeout(resolve, ms))
}
function Sidebar(props: {
route: AppRoute
setRoute: (route: AppRoute) => void
@@ -524,50 +559,76 @@ function AuthScreen({
error: string
}) {
const isPasswordValid = password.trim().length >= 8
const isSetup = mode === 'setup'
function handleSubmit() {
if (busy || !isPasswordValid) {
return
}
void onSubmit()
}
return (
<div className="auth-layout">
<section className="auth-panel">
<p className="eyebrow">{mode === 'setup' ? 'First boot' : 'Secure access'}</p>
<h1>{mode === 'setup' ? 'Create your master password' : 'Sign in to OmniArr'}</h1>
<p className="auth-copy">
{mode === 'setup'
? 'This password protects the session and encrypts service settings on the server.'
: 'The full backend remains protected behind the current session.'}
</p>
<div className="auth-form">
<label>
Password
<input
autoComplete={mode === 'setup' ? 'new-password' : 'current-password'}
className="input"
minLength={8}
onChange={(event) => setPassword(event.target.value)}
placeholder="At least 8 characters"
type="password"
value={password}
/>
</label>
{!isPasswordValid && password.length > 0 ? <p className="helper-text">Password must be at least 8 non-space characters.</p> : null}
{error ? <p className="error-banner">{error}</p> : null}
{busy ? <p className="notice">Contacting backend…</p> : null}
<button className="primary-button" disabled={busy || !isPasswordValid} onClick={() => void onSubmit()} type="button">
{busy ? 'Processing…' : mode === 'setup' ? 'Initialize' : 'Sign in'}
</button>
<div className={isSetup ? 'auth-layout' : 'auth-layout auth-layout-login'}>
<section className={isSetup ? 'auth-panel' : 'auth-panel auth-panel-login'}>
<div className="auth-panel-shell">
<p className="eyebrow">{isSetup ? 'First boot' : 'Secure access'}</p>
<h1>{isSetup ? 'Create your master password' : 'Sign in to OmniArr'}</h1>
<p className="auth-copy">
{isSetup
? 'This password protects the session and encrypts service settings on the server.'
: 'Unlock the server session with your master password.'}
</p>
</div>
<div className="auth-form-card">
<form
className="auth-form"
onSubmit={(event) => {
event.preventDefault()
handleSubmit()
}}
>
<label>
{isSetup ? 'Master password' : 'Password'}
<input
autoComplete={isSetup ? 'new-password' : 'current-password'}
className="input"
minLength={8}
onChange={(event) => setPassword(event.target.value)}
placeholder={isSetup ? 'At least 8 characters' : ''}
type="password"
value={password}
/>
</label>
{isSetup && !isPasswordValid && password.length > 0 ? <p className="helper-text">Password must be at least 8 non-space characters.</p> : null}
{error ? <p className="error-banner">{error}</p> : null}
{busy ? <p className="notice">Contacting backend…</p> : null}
<button className="primary-button" disabled={busy || !isPasswordValid} type="submit">
{busy ? 'Processing…' : isSetup ? 'Initialize' : 'Sign in'}
</button>
</form>
</div>
</section>
<section className="auth-visual">
<div className="auth-wallpaper" />
<div className="glass-card">
<p className="eyebrow">Migration</p>
<ul className="feature-list">
<li>Server-side session auth</li>
<li>Encrypted persisted settings</li>
<li>Jellyfin, Sonarr and Radarr</li>
<li>Rebuilt React UI with shared layout</li>
</ul>
</div>
</section>
{isSetup ? (
<section className="auth-visual">
<div className="auth-wallpaper" />
<div className="glass-card">
<p className="eyebrow">Migration</p>
<ul className="feature-list">
<li>Server-side session auth</li>
<li>Encrypted persisted settings</li>
<li>Jellyfin, Sonarr and Radarr</li>
<li>Rebuilt React UI with shared layout</li>
</ul>
</div>
</section>
) : (
<section className="auth-visual auth-visual-login" aria-hidden="true">
<div className="auth-wallpaper" />
</section>
)}
</div>
)
}
@@ -942,9 +1003,16 @@ function MediaTile(props: {
const imageUrl = props.styleType === 'landscape' || props.styleType === 'episode'
? (props.card.backdropUrl || props.card.posterUrl)
: props.card.posterUrl
const continueEpisodeMeta = props.isContinueWatching ? parseContinueEpisodeMeta(props.card) : null
const tileClassName = [
'media-tile',
props.styleType,
props.isContinueWatching ? 'continue-tile' : '',
props.isContinueWatching && props.card.progress ? 'has-progress' : '',
].filter(Boolean).join(' ')
return (
<article className={props.isContinueWatching ? `media-tile ${props.styleType} continue-tile` : `media-tile ${props.styleType}`}>
<article className={tileClassName}>
<button
className="media-art media-trigger"
onClick={(event) => {
@@ -954,7 +1022,13 @@ function MediaTile(props: {
type="button"
>
{imageUrl ? <img alt={props.card.title} loading="lazy" src={imageUrl} /> : <div className="media-fallback" />}
{props.card.hoverLabel ? <div className="media-hover-label">{props.card.hoverLabel}</div> : null}
{continueEpisodeMeta ? (
<div className="continue-episode-meta">
<span className="continue-episode-meta-primary">{`Season ${continueEpisodeMeta.seasonNumber}`}</span>
<span className="continue-episode-meta-secondary">{`Episode ${continueEpisodeMeta.episodeNumber}`}</span>
</div>
) : null}
{props.card.hoverLabel && !continueEpisodeMeta ? <div className="media-hover-label">{props.card.hoverLabel}</div> : null}
{props.card.progress ? <div className="tile-progress"><div className="tile-progress-fill" style={{ width: `${props.card.progress}%` }} /></div> : null}
</button>
</article>
@@ -1240,6 +1314,7 @@ function TitleDetailsModal(props: {
const canDownloadSeasonAction = Boolean(
activeSeasonDownloadStatus === 'processing'
|| activeSeasonDownloadStatus === 'downloading'
|| (details?.sonarrSeriesId && typeof activeSeasonNumber === 'number' && activeSeasonNumber > 0)
|| activeSeasonMeta?.canDownload
|| (canRequest && !details?.sonarrSeriesId && typeof activeSeasonNumber === 'number')
)
@@ -1760,6 +1835,18 @@ function formatEpisodeMeta(subtitle: string) {
return subtitle.replace(/^Season\s+\d+\s*,\s*/i, '')
}
function parseContinueEpisodeMeta(card: MediaCard) {
const match = `${card.subtitle} ${card.hoverLabel || ''}`.match(/\bS(\d{1,2})E(\d{1,3})\b/i)
if (!match) {
return null
}
return {
seasonNumber: Number(match[1]),
episodeNumber: Number(match[2]),
}
}
function truncateOverview(text: string, maxLength: number) {
if (text.length <= maxLength) {
return text
+213 -40
View File
@@ -52,6 +52,52 @@ img {
overflow: hidden;
}
.entry-stage-shell {
position: relative;
min-height: 100vh;
}
.entry-stage-shell::after {
content: "";
position: fixed;
inset: 0;
pointer-events: none;
opacity: 0;
background:
linear-gradient(115deg, transparent 18%, rgba(255, 209, 102, 0.12) 48%, rgba(104, 171, 255, 0.16) 62%, transparent 82%);
mix-blend-mode: screen;
}
.entry-stage-shell.is-forward-exit,
.entry-stage-shell.is-back-exit,
.entry-stage-shell.is-forward-enter,
.entry-stage-shell.is-back-enter {
overflow: hidden;
}
.entry-stage-shell.is-forward-exit {
animation: entryStageForwardExit 240ms cubic-bezier(0.32, 0.9, 0.42, 1) both;
}
.entry-stage-shell.is-forward-exit::after,
.entry-stage-shell.is-back-exit::after,
.entry-stage-shell.is-forward-enter::after,
.entry-stage-shell.is-back-enter::after {
animation: entryStageSweep 520ms ease both;
}
.entry-stage-shell.is-forward-enter {
animation: entryStageForwardEnter 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.entry-stage-shell.is-back-exit {
animation: entryStageBackExit 240ms cubic-bezier(0.32, 0.9, 0.42, 1) both;
}
.entry-stage-shell.is-back-enter {
animation: entryStageBackEnter 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.omniarr-sidebar {
position: fixed;
inset: 0 auto 0 0;
@@ -746,6 +792,7 @@ img {
pointer-events: none;
}
.continue-tile.has-progress .media-art::after,
.continue-tile:hover .media-art::after,
.continue-tile:focus-within .media-art::after {
opacity: 1;
@@ -757,6 +804,54 @@ img {
transform: translateY(0);
}
.continue-episode-meta {
position: absolute;
left: 0.85rem;
bottom: 1.05rem;
z-index: 2;
display: grid;
gap: 0.18rem;
text-align: left;
pointer-events: none;
opacity: 0;
transform: translateY(0.45rem);
text-shadow:
0 0.18rem 0.8rem rgba(0, 0, 0, 0.78),
0 0.04rem 0.12rem rgba(0, 0, 0, 0.7);
transition: opacity 180ms ease, transform 180ms ease;
}
.continue-tile.has-progress .continue-episode-meta {
bottom: 1.45rem;
}
.continue-episode-meta-primary {
color: #eef4ff;
font-size: 0.95rem;
font-weight: 700;
letter-spacing: 0.015em;
line-height: 1.1;
}
.continue-episode-meta-secondary {
color: rgba(226, 234, 247, 0.86);
font-size: 0.74rem;
font-weight: 500;
letter-spacing: 0.16em;
line-height: 1.1;
text-transform: uppercase;
}
.continue-tile .media-hover-label {
bottom: 3.55rem;
}
.continue-tile:hover .continue-episode-meta,
.continue-tile:focus-within .continue-episode-meta {
opacity: 1;
transform: translateY(0);
}
.landscape .media-art,
.episode .media-art {
aspect-ratio: 16 / 9;
@@ -1798,34 +1893,6 @@ img {
animation: playingNextUpBorderPulse 220ms ease-out 1 both;
}
.episode-card.is-playing-next-up.has-progress::after {
animation: playingNextUpBorderJoinPulse 220ms ease-out 1 both;
}
.episode-card.is-next-up.has-progress::after,
.episode-card.is-playing.has-progress::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
z-index: 3;
width: 7%;
min-width: 1.05rem;
height: 2px;
border-bottom-left-radius: 999px;
background: currentColor;
pointer-events: none;
}
.episode-card.is-next-up.has-progress::after {
color: #68abff;
}
.episode-card.is-playing.has-progress::after {
color: #79b8ff;
height: 4px;
}
.episode-card.is-next-up.has-progress .episode-card-art::before,
.episode-card.is-playing.has-progress .episode-card-art::before {
inset: 0;
@@ -1852,18 +1919,6 @@ img {
}
}
@keyframes playingNextUpBorderJoinPulse {
0% {
background: #68abff;
height: 2px;
}
100% {
background: #79b8ff;
height: 4px;
}
}
.episode-image-shell {
width: 100%;
height: 100%;
@@ -2349,6 +2404,17 @@ img {
min-height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr;
background:
radial-gradient(circle at top left, rgba(104, 171, 255, 0.18), transparent 32%),
linear-gradient(180deg, #05070b, #090c12 42%, #06080d 100%);
}
.auth-layout-login {
position: relative;
grid-template-columns: minmax(0, 34rem);
justify-content: center;
align-content: center;
padding: 2rem;
}
.auth-panel,
@@ -2362,11 +2428,37 @@ img {
gap: 1.25rem;
}
.auth-panel-login {
position: relative;
z-index: 1;
min-height: auto;
padding: 0;
}
.auth-panel-shell {
display: grid;
gap: 1rem;
}
.auth-copy {
margin: 0;
color: #adbfd8;
}
.auth-form-card {
display: grid;
gap: 1rem;
margin-top: 0.25rem;
padding: 1.35rem;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 1.35rem;
background: rgba(9, 12, 18, 0.74);
box-shadow:
0 1.4rem 3rem rgba(0, 0, 0, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.04);
backdrop-filter: blur(18px);
}
.auth-form {
display: grid;
gap: 1rem;
@@ -2385,6 +2477,15 @@ img {
url('/omniarr/server-wallpaper.png') center/cover no-repeat;
}
.auth-visual-login {
position: fixed;
inset: 0;
z-index: 0;
padding: 0;
opacity: 0.6;
mask-image: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.88) 18%, #000 100%);
}
.glass-card {
position: relative;
z-index: 1;
@@ -2515,6 +2616,78 @@ img {
100% { background-position: -200% 0; }
}
@keyframes entryStageForwardExit {
0% {
opacity: 1;
transform: scale(1) translateX(0);
filter: blur(0);
}
100% {
opacity: 0;
transform: scale(0.975) translateX(-2.2rem);
filter: blur(14px);
}
}
@keyframes entryStageForwardEnter {
0% {
opacity: 0;
transform: scale(1.03) translateX(3.6rem);
filter: blur(16px);
}
100% {
opacity: 1;
transform: scale(1) translateX(0);
filter: blur(0);
}
}
@keyframes entryStageBackExit {
0% {
opacity: 1;
transform: scale(1) translateX(0);
filter: blur(0);
}
100% {
opacity: 0;
transform: scale(0.982) translateX(2.2rem);
filter: blur(12px);
}
}
@keyframes entryStageBackEnter {
0% {
opacity: 0;
transform: scale(1.02) translateX(-3.2rem);
filter: blur(16px);
}
100% {
opacity: 1;
transform: scale(1) translateX(0);
filter: blur(0);
}
}
@keyframes entryStageSweep {
0% {
opacity: 0;
transform: translateX(-18%);
}
24% {
opacity: 1;
}
100% {
opacity: 0;
transform: translateX(18%);
}
}
@media (max-width: 980px) {
.content-shell {
margin-left: 0;