Vérification complète : moins de requêtes TMDB inutiles, bilan plus léger
deploy / deploy (push) Successful in 1m7s
deploy / deploy (push) Successful in 1m7s
- Une saison annoncée mais pas encore créée chez TMDB (404) était redemandée à chaque ouverture : elle est maintenant gardée 3 h comme saison vide (10 min dans le calendrier des sorties). - Le bouton et la carte du bilan comptent les titres terminés sans calculer tout le bilan à chaque changement de la bibliothèque. - Bilan : les flèches du clavier ne tournent plus les pages derrière l'aperçu de l'image. - terser (outil de compilation) passe en 5.51.4, version corrigée. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
6 files changed
+28
-10
No files matched your search
Generated
+3
-3
@@ -6076,9 +6076,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/terser": {
|
"node_modules/terser": {
|
||||||
"version": "5.51.2",
|
"version": "5.51.4",
|
||||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.51.2.tgz",
|
"resolved": "https://registry.npmjs.org/terser/-/terser-5.51.4.tgz",
|
||||||
"integrity": "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==",
|
"integrity": "sha512-VPi1CkDvCWLGUVIToctNBG+NdHbSXwOPjHJnQ3pdB0XknaldnI76wSkAFOGxV2ZdkzOP5d6gpQ5c58XvDghRvw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Sparkles, X } from 'lucide-react'
|
import { Sparkles, X } from 'lucide-react'
|
||||||
import { lazy, Suspense, useMemo, useState } from 'react'
|
import { lazy, Suspense, useMemo, useState } from 'react'
|
||||||
import { t } from '../i18n'
|
import { t } from '../i18n'
|
||||||
import { recapSeasonYear, yearRecap } from '../lib/recap'
|
import { finishedInYear, recapSeasonYear, yearRecap } from '../lib/recap'
|
||||||
import type { MediaItem } from '../types'
|
import type { MediaItem } from '../types'
|
||||||
|
|
||||||
// Les pages du bilan ne sont chargées qu'à l'ouverture
|
// Les pages du bilan ne sont chargées qu'à l'ouverture
|
||||||
@@ -20,7 +20,7 @@ function RecapViewer({ items, year, onClose, onSeeStats }: { items: MediaItem[];
|
|||||||
/** Bouton « Mon année 2026 » de la page Stats (si l'année a au moins un titre terminé). */
|
/** Bouton « Mon année 2026 » de la page Stats (si l'année a au moins un titre terminé). */
|
||||||
export function RecapButton({ items, year }: { items: MediaItem[]; year: string }) {
|
export function RecapButton({ items, year }: { items: MediaItem[]; year: string }) {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const finished = useMemo(() => yearRecap(items, year).finished, [items, year])
|
const finished = useMemo(() => finishedInYear(items, year), [items, year])
|
||||||
if (!finished) return null
|
if (!finished) return null
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -41,7 +41,7 @@ const hiddenKey = (year: string) => `azuucine:recap-hint-${year}`
|
|||||||
*/
|
*/
|
||||||
export function RecapHint({ items, onSeeStats }: { items: MediaItem[]; onSeeStats: () => void }) {
|
export function RecapHint({ items, onSeeStats }: { items: MediaItem[]; onSeeStats: () => void }) {
|
||||||
const year = recapSeasonYear()
|
const year = recapSeasonYear()
|
||||||
const finished = useMemo(() => (year ? yearRecap(items, year).finished : 0), [items, year])
|
const finished = useMemo(() => (year ? finishedInYear(items, year) : 0), [items, year])
|
||||||
const [hidden, setHidden] = useState(() => {
|
const [hidden, setHidden] = useState(() => {
|
||||||
try {
|
try {
|
||||||
return !!year && localStorage.getItem(hiddenKey(year)) === '1'
|
return !!year && localStorage.getItem(hiddenKey(year)) === '1'
|
||||||
|
|||||||
@@ -174,6 +174,8 @@ export default function YearRecap({ recap, onClose, onSeeStats }: { recap: Recap
|
|||||||
const go = (d: number) => setPage((p) => Math.min(last, Math.max(0, p + d)))
|
const go = (d: number) => setPage((p) => Math.min(last, Math.max(0, p + d)))
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Aperçu de l'image ouvert par-dessus : les flèches ne tournent pas les pages derrière
|
||||||
|
if (share) return
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'ArrowRight') go(document.dir === 'rtl' ? -1 : 1)
|
if (e.key === 'ArrowRight') go(document.dir === 'rtl' ? -1 : 1)
|
||||||
else if (e.key === 'ArrowLeft') go(document.dir === 'rtl' ? 1 : -1)
|
else if (e.key === 'ArrowLeft') go(document.dir === 'rtl' ? 1 : -1)
|
||||||
@@ -181,7 +183,7 @@ export default function YearRecap({ recap, onClose, onSeeStats }: { recap: Recap
|
|||||||
window.addEventListener('keydown', onKey)
|
window.addEventListener('keydown', onKey)
|
||||||
return () => window.removeEventListener('keydown', onKey)
|
return () => window.removeEventListener('keydown', onKey)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [last])
|
}, [last, share])
|
||||||
|
|
||||||
async function makeShare() {
|
async function makeShare() {
|
||||||
setBusy(true)
|
setBusy(true)
|
||||||
|
|||||||
+12
-2
@@ -149,7 +149,7 @@ async function tmdbFetch<T>(path: string, key: string, params: Record<string, st
|
|||||||
signal: timeout(),
|
signal: timeout(),
|
||||||
})
|
})
|
||||||
if (res.status === 401) throw new Error(t('err.tmdbKeyRefused'))
|
if (res.status === 401) throw new Error(t('err.tmdbKeyRefused'))
|
||||||
if (!res.ok) throw new Error(t('err.tmdbStatus', { status: res.status }))
|
if (!res.ok) throw Object.assign(new Error(t('err.tmdbStatus', { status: res.status })), { status: res.status })
|
||||||
return res.json() as Promise<T>
|
return res.json() as Promise<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,6 +336,8 @@ export interface EpisodeInfo {
|
|||||||
// de la fiche, puis est rafraîchie en arrière-plan si elle date de plus de 12 h (nouveaux épisodes, images)
|
// de la fiche, puis est rafraîchie en arrière-plan si elle date de plus de 12 h (nouveaux épisodes, images)
|
||||||
const SEASONS_KEY = 'azuucine:seasons'
|
const SEASONS_KEY = 'azuucine:seasons'
|
||||||
const SEASONS_FRESH = 12 * 3600_000
|
const SEASONS_FRESH = 12 * 3600_000
|
||||||
|
/** Saison introuvable chez TMDB (annoncée mais pas encore créée) : on ne la redemande pas avant 3 h. */
|
||||||
|
const SEASON_MISSING_FOR = 3 * 3600_000
|
||||||
const SEASONS_MAX_AGE = 30 * 24 * 3600_000
|
const SEASONS_MAX_AGE = 30 * 24 * 3600_000
|
||||||
const SEASONS_BUDGET = 400_000
|
const SEASONS_BUDGET = 400_000
|
||||||
type SeasonEntry = { at: number; eps: EpisodeInfo[] }
|
type SeasonEntry = { at: number; eps: EpisodeInfo[] }
|
||||||
@@ -428,6 +430,13 @@ export async function getTmdbSeasonEpisodes(externalId: string, season: number,
|
|||||||
saveSeasons()
|
saveSeasons()
|
||||||
return list
|
return list
|
||||||
})
|
})
|
||||||
|
.catch((e: unknown) => {
|
||||||
|
if ((e as { status?: number })?.status !== 404) throw e
|
||||||
|
// Gardée comme une saison vide, « périmée » au bout de 3 h au lieu de 12 (elle peut arriver bientôt)
|
||||||
|
seasonsStore().set(cacheKey, { at: Date.now() - SEASONS_FRESH + SEASON_MISSING_FOR, eps: [] })
|
||||||
|
saveSeasons()
|
||||||
|
return [] as EpisodeInfo[]
|
||||||
|
})
|
||||||
.finally(() => seasonsInflight.delete(cacheKey))
|
.finally(() => seasonsInflight.delete(cacheKey))
|
||||||
seasonsInflight.set(cacheKey, p)
|
seasonsInflight.set(cacheKey, p)
|
||||||
}
|
}
|
||||||
@@ -884,7 +893,8 @@ function sharedTmdb<T>(path: string, key: string): Promise<T> {
|
|||||||
job = tmdbFetch<T>(path, key)
|
job = tmdbFetch<T>(path, key)
|
||||||
showJobs.set(id, job)
|
showJobs.set(id, job)
|
||||||
const forget = () => setTimeout(() => showJobs.delete(id), 10 * 60_000)
|
const forget = () => setTimeout(() => showJobs.delete(id), 10 * 60_000)
|
||||||
job.then(forget, () => showJobs.delete(id))
|
// Une saison introuvable (404) n'est pas redemandée pendant 10 min ; une autre erreur, oui (réseau…)
|
||||||
|
job.then(forget, (e: unknown) => ((e as { status?: number })?.status === 404 ? forget() : showJobs.delete(id)))
|
||||||
}
|
}
|
||||||
return job
|
return job
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ export async function tmdbViaCloud<T>(path: string, params: Record<string, strin
|
|||||||
const q = new URLSearchParams({ path, ...params })
|
const q = new URLSearchParams({ path, ...params })
|
||||||
const res = await publicFetch(`/functions/v1/tmdb?${q}`)
|
const res = await publicFetch(`/functions/v1/tmdb?${q}`)
|
||||||
if (res.status === 429) throw new Error(t('err.searchRate'))
|
if (res.status === 429) throw new Error(t('err.searchRate'))
|
||||||
if (!res.ok) throw new Error(t('err.tmdbStatus', { status: res.status }))
|
// Le code HTTP reste lisible (404 : saison pas encore créée chez TMDB, inutile de redemander tout de suite)
|
||||||
|
if (!res.ok) throw Object.assign(new Error(t('err.tmdbStatus', { status: res.status })), { status: res.status })
|
||||||
return res.json() as Promise<T>
|
return res.json() as Promise<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ export function yearRecap(items: MediaItem[], year: string): YearRecap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Titres terminés dans l'année : de quoi décider d'afficher le bilan, sans tout calculer. */
|
||||||
|
export function finishedInYear(items: MediaItem[], year: string): number {
|
||||||
|
return itemsForPeriod(items, year).filter((i) => i.status === 'termine').length
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Année dont le bilan est mis en avant sur l'accueil : l'année en cours en décembre, l'année passée en janvier.
|
* Année dont le bilan est mis en avant sur l'accueil : l'année en cours en décembre, l'année passée en janvier.
|
||||||
* Le reste du temps, aucun (le bilan reste accessible depuis les stats).
|
* Le reste du temps, aucun (le bilan reste accessible depuis les stats).
|
||||||
|
|||||||
Reference in new issue
Block a user