Défis de visionnage : objectifs, progression automatique et carte sur l'accueil

- Défis (films / séries / animes / K-dramas / C-dramas / autres / tout ; titres
  terminés ou épisodes vus ; semaine, mois, année ou dates libres), modèles en un tap.
- Progression calculée depuis la bibliothèque : dates de fin + revisionnages ;
  épisodes via un journal privé par jour (episodeLog) rempli à chaque coche,
  avec estimation (répartition début→fin) pour les épisodes sans date.
- Carte « Défis » sur l'accueil (anneau, rythme « 3 films d'avance »),
  feuille de gestion (créer, modifier, archiver, recommencer, supprimer,
  titres comptés → fiche), date de réussite, petite célébration sobre.
- Stockage dans les réglages synchronisés (15 max), inclus dans l'export/import
  (fusion des défis en mode « fusionner »). 18 langues.
- Migration 20261009140000_challenges.sql : réglages jusqu'à 16 000 octets et
  episodeLog retiré des fiches publiques.

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-09 15:19:58 +00:00
1 parent c246b16e7e
commit 308c0f2327
30 files changed
+2472 -6

No files matched your search

+9 -4
View File
@@ -16,6 +16,7 @@ import { episodesPatch } from './lib/progress'
import { uid } from './lib/utils'
import { episodeCap } from './lib/franchise'
import { airedCount } from './lib/airing'
import { logEpisodes } from './lib/challenges'
// Clés propres à l'espace actif (compte connecté, ou appareil sans compte)
const settingsKey = () => scopedKey('settings')
@@ -169,8 +170,8 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
getLists: () => listsRef.current,
applyLists: (next) => setLists(() => next, true),
getSettings: () => {
const { ratingScale, topCategories, accentColor, themeMode, notifPrefs } = settingsRef.current
return { ratingScale, topCategories, accentColor, themeMode, notifPrefs }
const { ratingScale, topCategories, accentColor, themeMode, notifPrefs, challenges } = settingsRef.current
return { ratingScale, topCategories, accentColor, themeMode, notifPrefs, challenges }
},
applySettings: (patch) => updateSettingsRef.current(patch, true),
itemsChanged: () => void reloadItems(),
@@ -211,7 +212,7 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
}, [settings.themeMode])
const updateSettings = useCallback((patch: Partial<Settings>, silent = false) => {
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch || 'notifPrefs' in patch)) syncRef.current.markSettings()
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch || 'notifPrefs' in patch || 'challenges' in patch)) syncRef.current.markSettings()
setSettings((prev) => {
const next = { ...prev, ...patch }
try {
@@ -248,7 +249,11 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
async (id: string, patch: Partial<MediaInput>) => {
const current = itemsRef.current.find((i) => i.id === id)
if (!current) return
await save({ ...current, ...patch, updatedAt: new Date().toISOString() })
const next = { ...current, ...patch, updatedAt: new Date().toISOString() }
// Défis : on retient le jour où des épisodes sont cochés (ou décochés)
const delta = (patch.episodesWatched ?? current.episodesWatched) - current.episodesWatched
if (delta) next.episodeLog = logEpisodes(current.episodeLog, delta)
await save(next)
},
[save],
)