From f3b7d0c025aeb238fa601dcd32f946a0adb514ee Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 15:13:59 +0000 Subject: [PATCH] =?UTF-8?q?Note=20Trakt=20affich=C3=A9e=20tout=20de=20suit?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Gardée sur l'appareil : une fiche déjà ouverte affiche sa note et sa répartition immédiatement (et hors-ligne), rafraîchie en arrière-plan - La fiche n'attend plus Trakt pour le casting et « Où regarder » ; pendant le premier chargement, place réservée sans chiffre provisoire (plus de bascule TMDB → Trakt) - Préchargement dès qu'on touche une affiche (ou qu'on la survole à la souris) : la fiche s'ouvre avec ses infos - Serveur : notes Trakt gardées 24 h pour tout le monde (table title_ratings), correspondance TMDB → Trakt gardée pour toujours ; une note plus ancienne est renvoyée tout de suite puis rafraîchie Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe --- src/App.tsx | 21 ++- src/components/CalendarView.tsx | 2 +- src/components/HomeHero.tsx | 6 +- src/components/JournalView.tsx | 2 +- src/components/LatestReleases.tsx | 2 +- src/components/MediaCard.tsx | 4 +- src/components/TopFive.tsx | 6 +- src/components/person/PersonSheet.tsx | 2 +- src/components/social/ProfileView.tsx | 2 +- src/components/title/AddTitle.tsx | 2 +- src/components/title/TitleSheet.tsx | 66 ++++++-- src/lib/catalogApi.ts | 116 ++++++++++++-- src/lib/cloud/api.ts | 5 +- src/pages/HomePage.tsx | 2 +- supabase/functions/ratings/index.ts | 148 ++++++++++++++---- .../20261129150000_title_ratings_cache.sql | 15 ++ 16 files changed, 326 insertions(+), 75 deletions(-) create mode 100644 supabase/migrations/20261129150000_title_ratings_cache.sql diff --git a/src/App.tsx b/src/App.tsx index 81a182b..700a97d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,7 +7,7 @@ import HomePage from './pages/HomePage' import CatalogPage from './pages/CatalogPage' import SyncIndicator from './components/SyncIndicator' import { useMedia } from './store' -import type { SearchResult } from './lib/catalogApi' +import { prefetchTitle, setPrefetchKey, type SearchResult } from './lib/catalogApi' import type { MediaItem } from './types' import type { Completion } from './lib/seasons' @@ -65,7 +65,24 @@ type Layer = let layerUid = 0 export default function App() { - const { error } = useMedia() + const { error, settings } = useMedia() + + // Préchargement d'une fiche dès qu'on touche (ou survole à la souris) une affiche marquée data-prefetch : + // infos TMDB et note Trakt arrivent pendant l'appui, la fiche s'ouvre avec tout déjà là + useEffect(() => setPrefetchKey(settings.tmdbKey), [settings.tmdbKey]) + useEffect(() => { + const onPointer = (e: PointerEvent) => { + if (e.type === 'pointerover' && e.pointerType !== 'mouse') return + const el = e.target instanceof Element ? e.target.closest('[data-prefetch]') : null + if (el) prefetchTitle(el.getAttribute('data-prefetch')) + } + document.addEventListener('pointerdown', onPointer, { capture: true, passive: true }) + document.addEventListener('pointerover', onPointer, { passive: true }) + return () => { + document.removeEventListener('pointerdown', onPointer, { capture: true }) + document.removeEventListener('pointerover', onPointer) + } + }, []) const [route, setRoute] = useState(routeFromHash) const [layers, setLayers] = useState<(Layer & { uid: number })[]>([]) const pushLayer = (l: Layer) => setLayers((ls) => [...ls.slice(-11), { ...l, uid: ++layerUid }]) diff --git a/src/components/CalendarView.tsx b/src/components/CalendarView.tsx index f1fcc5c..8e014a4 100644 --- a/src/components/CalendarView.tsx +++ b/src/components/CalendarView.tsx @@ -71,7 +71,7 @@ function EntryRow({ e, onOpen, onAdd, busy, added }: { e: Entry; onOpen: (i: Med ) if (mine) { return ( - diff --git a/src/components/HomeHero.tsx b/src/components/HomeHero.tsx index 781b7e0..c92e60f 100644 --- a/src/components/HomeHero.tsx +++ b/src/components/HomeHero.tsx @@ -110,7 +110,7 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen if (Math.abs(dx) > 45) go(current + (dx < 0 ? 1 : -1)) }} > - @@ -196,7 +196,7 @@ export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item: return (
- @@ -69,7 +69,7 @@ export const MediaCard = memo(function MediaCard({ item, onOpen }: { item: Media )} - ) : ( @@ -121,7 +121,7 @@ export default function TopFive({ onOpen, items: others }: { onOpen: (item: Medi {t('top.number', { rank: 1 })} · {current.plural} {first ? ( <> -
@@ -149,7 +149,7 @@ export default function TopFive({ onOpen, items: others }: { onOpen: (item: Medi
{item ? ( - ) : ( diff --git a/src/components/person/PersonSheet.tsx b/src/components/person/PersonSheet.tsx index 1005cc0..44366f6 100644 --- a/src/components/person/PersonSheet.tsx +++ b/src/components/person/PersonSheet.tsx @@ -174,7 +174,7 @@ export default function PersonSheet({ const it = mine(c.result) return (
  • -