Revisionnage : revoir un film ou une série déjà terminés

- Bloc « Revoir » sur la fiche d'un titre terminé, avec le nombre de visionnages (« Vu 3 fois »).
- Film : « Revu le … » à la date choisie (aujourd'hui par défaut), annulable.
- Série : « Commencer un revisionnage » avec sa propre progression d'épisodes
  (Reprendre, +1, liste d'épisodes), badge « Revisionnage » sur l'accueil.
  Le premier visionnage reste intact (statut, dates, note, notes de saison).
  Au dernier épisode, le revisionnage se termine et rejoint l'historique ;
  on peut aussi le terminer d'un coup ou l'arrêter.
- Les épisodes revus comptent pour les défis ; le temps des revisionnages de séries
  compte dans les stats et le journal.
- Données dans la fiche (champ rewatch), synchronisées et sauvegardées, rien côté SQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-10-18 18:04:38 +00:00
1 parent e1cd166366
commit 1433fc627c
29 files changed
+644 -39

No files matched your search

+45 -21
View File
@@ -30,6 +30,8 @@ import EditDetails from './EditDetails'
import ReviewEditor from './ReviewEditor'
import WhereToWatch from './WhereToWatch'
import SeasonRatings from './SeasonRatings'
import RewatchPanel from './RewatchPanel'
import { progressView, rewatchEpisodesPatch } from '../../lib/rewatch'
import { completionOf, hasSeasons, seasonsAverage, type Completion } from '../../lib/seasons'
import ReviewComments from '../social/ReviewComments'
import SharedListPicker from '../social/SharedListPicker'
@@ -233,8 +235,16 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
if (focus && 'final' in focus) ratingRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
}, [focus])
// Revisionnage qui vient de se terminer (dernier épisode coché ici)
const [rewatchDone, setRewatchDone] = useState(false)
const setEpisodes = (n: number, season?: number) => {
if (!item) return
// Revisionnage : sa propre progression, le premier visionnage reste tel quel
if (item.rewatch) {
const { patch, finished } = rewatchEpisodesPatch(item, n)
void update(item.id, patch).then(() => finished && setRewatchDone(true))
return
}
const done = completionOf(item, item.episodesWatched, n)
void update(item.id, episodesPatch(item, n, season)).then(() => done && setFocus(done))
}
@@ -244,16 +254,18 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
const airingRef = item ? { id: item.id, type: item.type, externalId: item.externalId } : undefined
const aired = airingRef ? airedCount(airingRef, airingCache) : undefined
/** Bouton principal des épisodes : « J'ai vu S2 · É3 », « À jour », « Tout vu »… */
// Pendant un revisionnage, les épisodes affichés sont ceux du revisionnage
const shown = item ? progressView(item) : undefined
const nextEpisode = (() => {
if (!item || !episodic) return undefined
const cap = episodeCap(item)
if (cap && item.episodesWatched >= cap) return { label: t('hero.allSeen'), done: true }
if (aired != null && item.episodesWatched >= aired) {
if (!shown || !episodic) return undefined
const cap = episodeCap(shown)
if (cap && shown.episodesWatched >= cap) return { label: t('hero.allSeen'), done: true }
if (aired != null && shown.episodesWatched >= aired) {
const date = airingRef ? nextAirDate(airingRef, airingCache) : undefined
return { label: date ? t('hero.nextOn', { date: formatDate(date) }) : t('hero.upToDate'), done: true }
}
const pos = seasonPosition({ ...item, episodesWatched: item.episodesWatched + 1, season: undefined })
const ep = t('episodes.short', { n: pos ? pos.episode : item.episodesWatched + 1 })
const pos = seasonPosition({ ...shown, episodesWatched: shown.episodesWatched + 1, season: undefined })
const ep = t('episodes.short', { n: pos ? pos.episode : shown.episodesWatched + 1 })
return { label: t('hero.seenEp', { ep: pos ? `${t('episodes.seasonShort', { n: pos.season })} · ${ep}` : ep }), done: false }
})()
const hasEpisodeList = !!item && (!!item.seasons || (!!item.externalId && !!item.episodesTotal))
@@ -453,12 +465,29 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
)}
</section>
{/* Revoir (titre terminé) */}
{item && item.status === 'termine' && (
<RewatchPanel
item={item}
justFinished={rewatchDone}
onChange={(patch) => {
setRewatchDone(false)
void update(item.id, patch)
}}
onUndoable={(patch, message) => {
const before = item
setRewatchDone(false)
void update(item.id, patch).then(() => actions.offerUndo(message, [before]))
}}
/>
)}
{/* Épisodes */}
{item && episodic && (
{item && shown && episodic && (
<section className="mx-4 mt-4">
{nextEpisode && (
<button
onClick={nextEpisode.done ? undefined : () => setEpisodes(item.episodesWatched + 1)}
onClick={nextEpisode.done ? undefined : () => setEpisodes(shown.episodesWatched + 1)}
disabled={nextEpisode.done}
className={cx('btn mb-3 w-full py-3', nextEpisode.done ? 'btn-ghost' : 'btn-primary')}
>
@@ -467,29 +496,29 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
</button>
)}
{hasEpisodeList ? (
<EpisodeList form={item} aired={aired} onChange={setEpisodes} />
<EpisodeList form={shown} aired={aired} onChange={setEpisodes} />
) : (
<div className="card p-4">
<div className="flex items-center justify-between gap-3">
<div>
<span className="eyebrow">{t('home.episodesSeen')}</span>
<p className="mt-1 text-2xl font-bold tabular-nums">
{item.episodesWatched}
{episodeCap(item) ? <span className="text-base font-normal text-ink-3"> / {episodeCap(item)}</span> : null}
{shown.episodesWatched}
{episodeCap(shown) ? <span className="text-base font-normal text-ink-3"> / {episodeCap(shown)}</span> : null}
</p>
</div>
<div className="flex items-center gap-2">
<button onClick={() => setEpisodes(item.episodesWatched - 1)} className="grid size-11 place-items-center rounded-full border border-line-strong text-ink-2" aria-label={t('form.minusEp')}>
<button onClick={() => setEpisodes(shown.episodesWatched - 1)} className="grid size-11 place-items-center rounded-full border border-line-strong text-ink-2" aria-label={t('form.minusEp')}>
<Minus size={18} />
</button>
<button onClick={() => setEpisodes(item.episodesWatched + 1)} className="grid size-11 place-items-center rounded-full bg-accent-fill text-on-accent" aria-label={t('form.plusEp')}>
<button onClick={() => setEpisodes(shown.episodesWatched + 1)} className="grid size-11 place-items-center rounded-full bg-accent-fill text-on-accent" aria-label={t('form.plusEp')}>
<Plus size={18} strokeWidth={2.5} />
</button>
</div>
</div>
{episodeCap(item) ? (
{episodeCap(shown) ? (
<div className="mt-3 h-1 rounded-full bg-surface-2">
<div className="h-full rounded-full bg-accent" style={{ width: `${Math.min(100, (item.episodesWatched / episodeCap(item)!) * 100)}%` }} />
<div className="h-full rounded-full bg-accent" style={{ width: `${Math.min(100, (shown.episodesWatched / episodeCap(shown)!) * 100)}%` }} />
</div>
) : null}
</div>
@@ -869,12 +898,7 @@ function Tracking({ item, lists, tagSuggestions, onChange }: { item: MediaItem;
))}
</ul>
)}
<button
onClick={() => rewatches.length < 100 && onChange({ rewatchDates: [todayISO(), ...rewatches].sort().reverse() })}
className="btn btn-ghost py-2 text-sm"
>
<Plus size={16} /> {t('title.rewatchedToday')}
</button>
{!rewatches.length && <p className="text-xs text-ink-3">{t('rewatch.historyEmpty')}</p>}
</div>
</div>
)}