diff --git a/src/App.tsx b/src/App.tsx index 6d07a8e..9339ebb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,6 +20,7 @@ import SyncIndicator from './components/SyncIndicator' import { useMedia } from './store' import type { SearchResult } from './lib/catalogApi' import type { MediaItem } from './types' +import type { Completion } from './lib/seasons' const TABS: Tab[] = ['home', 'catalog', 'stats', 'settings'] // L'administration a sa propre route (#/admin), hors de la navigation principale @@ -40,7 +41,7 @@ function routeFromHash(): Route { * ou page d'une personne. Titre → acteur → autre titre → … : « retour » remonte d'un cran. */ type Layer = - | { kind: 'title'; item: MediaItem; seed?: undefined } + | { kind: 'title'; item: MediaItem; seed?: undefined; focus?: Completion } | { kind: 'title'; seed: SearchResult; item?: undefined } | { kind: 'person'; personId: string; name?: string; photo?: string } let layerUid = 0 @@ -69,7 +70,8 @@ export default function App() { // Dans la barre de navigation, l'administration reste rattachée à « Réglages » const navTab: Tab = route === 'admin' ? 'settings' : route === 'notfound' ? 'home' : route - const openItem = (item: MediaItem) => pushLayer({ kind: 'title', item }) + /** `focus` : saison (ou série) qu'on vient de finir avec +1 → la fiche s'ouvre sur la note */ + const openItem = (item: MediaItem, focus?: Completion) => pushLayer({ kind: 'title', item, focus }) const openSeed = (seed: SearchResult) => pushLayer({ kind: 'title', seed }) const openPerson = (p: { id: string; name?: string; photo?: string }) => pushLayer({ kind: 'person', personId: p.id, name: p.name, photo: p.photo }) const openNew = () => setAdding(true) @@ -122,6 +124,7 @@ export default function App() { onClose={() => closeLayer(l.uid)} onGoToSettings={toSettings} onOpenPerson={openPerson} + focus={l.item ? l.focus : undefined} /> ) : ( void }) { +export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen: (item: MediaItem, focus?: Completion) => void }) { const { incrementEpisode } = useMedia() // On retient le titre affiché (et pas sa position) : la liste se réordonne quand on avance un épisode const [currentId, setCurrentId] = useState() @@ -106,7 +107,8 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen {next && (