App plus fluide : accueil stable, moins de réseau, synchro et base allégées
deploy / deploy (push) Successful in 47s
deploy / deploy (push) Successful in 47s
Accueil - Place de la bannière réservée pendant la lecture de la bibliothèque : plus de saut au démarrage (décalage 0,44 → 0). - Bannière : seules l'image affichée, la suivante et la précédente sont chargées (≈ 800 Ko de moins sur téléphone), image décodée avant d'être montrée, pas de défilement automatique hors écran, sous le doigt ou en animations réduites. - « Dernières sorties » : mise à jour seulement quand la rangée approche de l'écran ; fiche et saisons d'une série partagées entre les deux mois ; cache lu une fois par lancement (plus à chaque retour sur l'accueil). - « À voir » tiré au hasard une fois par jour (plus de nouvelles affiches à chaque ouverture). - Fil des abonnements : plus de double chargement, pas de nouvelle demande en revenant sur l'accueil (2 min). Fluidité - Store découpé : les actions (useMediaActions) et l'état de la synchro (useSyncStatus) ne redessinent plus toute l'app ; fiches inchangées conservées après une synchro. - Changement d'onglet en transition (onglet surligné tout de suite), catalogue par tranches de 24, cartes mémorisées avec fonctions stables, accueil et catalogue mémorisés. - Formateurs de dates et nombres gardés en mémoire ; longues listes d'épisodes : lignes hors écran non dessinées. - Sans flou sur les barres fixes ; page figée derrière une fiche juste après son apparition ; pas d'écouteur de molette sur téléphone ; double tap sans délai ; barre du bas masquée pendant la saisie. Réseau - Proxy TMDB et notes Trakt appelés sans en-tête : plus de pré-requête CORS (0 au lieu d'une par appel). - Images TMDB / AniList en mode CORS, cache posters-v2 / backdrops-v2 (les copies opaques comptaient ~7 Mo de quota chacune). - Synchro : curseur « réglé » (les dernières fiches ne sont plus retéléchargées chaque minute), rythme 1 min après une activité, 3 min au repos, plus de double synchro au retour sur l'app. - Pré-téléchargement allégé (pages légales, police en double, grandes icônes). Base (migration 20261129180000_write_path_perf, appliquée) - Notifications aux abonnés en une requête ; quota vérifié une fois par envoi ; fiche identique non réécrite ; index inutilisé supprimé. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
46 files changed
+680
-191
No files matched your search
@@ -4,14 +4,14 @@ import { t } from '../i18n'
|
||||
import { KeyRound, Loader2, LogOut, UserRound } from 'lucide-react'
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { PASSWORD_MIN, updatePassword } from '../lib/cloud/auth'
|
||||
import type { AccountApi } from '../store'
|
||||
import { useSyncStatus, type AccountApi } from '../store'
|
||||
import ConfirmDialog from './ConfirmDialog'
|
||||
import { SectionTitle } from './ui'
|
||||
import TwoFactor from './TwoFactor'
|
||||
|
||||
/** Réglages → Mon compte : mot de passe, déconnexion. La synchro tourne en arrière-plan. */
|
||||
export default function AccountSection({ account, onMessage }: { account: AccountApi; onMessage: (kind: 'ok' | 'error', text: string) => void }) {
|
||||
const { sync } = account
|
||||
const sync = useSyncStatus() ?? { state: 'idle' as const, pending: 0 }
|
||||
const social = useSocial()
|
||||
const [pwOpen, setPwOpen] = useState(false)
|
||||
const [pw, setPw] = useState('')
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function BottomNav({ current, onChange, onAdd }: Props) {
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className="safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg/95 backdrop-blur-md lg:hidden">
|
||||
<nav className="bottom-nav safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg lg:hidden">
|
||||
<div className="mx-auto flex max-w-2xl items-center px-2">
|
||||
{ITEMS.slice(0, 2).map(button)}
|
||||
<div className="flex flex-1 justify-center">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { locale, t } from '../i18n'
|
||||
import { dateFormat, locale, t } from '../i18n'
|
||||
import { Check, ChevronLeft, ChevronRight, Loader2, Plus, RefreshCw, X } from 'lucide-react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { loadAiring, refreshAiring, saveAiring } from '../lib/airing'
|
||||
@@ -19,7 +19,7 @@ import { TypeBadge } from './Badges'
|
||||
import Poster from './Poster'
|
||||
|
||||
// Initiales des jours, du lundi au dimanche, dans la langue choisie (le 1er janvier 2024 est un lundi)
|
||||
const weekdays = () => Array.from({ length: 7 }, (_, k) => new Date(2024, 0, 1 + k).toLocaleDateString(locale(), { weekday: 'narrow' }))
|
||||
const weekdays = () => Array.from({ length: 7 }, (_, k) => dateFormat({ weekday: 'narrow' }).format(new Date(2024, 0, 1 + k)))
|
||||
const PER_DAY = 20
|
||||
const PREFS_KEY = 'azuucine:calendar-prefs'
|
||||
/** Jour local décalé de n jours (sans « + n × 24 h », faux aux changements d'heure). */
|
||||
@@ -29,7 +29,7 @@ const plusDays = (n: number) => {
|
||||
}
|
||||
const iso = (d: Date) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
||||
const monthId = (d: Date) => iso(d).slice(0, 7)
|
||||
const niceDate = (d: string) => new Date(d + 'T12:00:00').toLocaleDateString(locale(), { weekday: 'long', day: 'numeric', month: 'long' })
|
||||
const niceDate = (d: string) => dateFormat({ weekday: 'long', day: 'numeric', month: 'long' }).format(new Date(d + 'T12:00:00'))
|
||||
|
||||
type Mode = 'all' | 'mine'
|
||||
|
||||
@@ -389,7 +389,7 @@ export default function CalendarView({ onClose, onOpen }: { onClose: () => void;
|
||||
<button onClick={() => changeMonth(-1)} className="grid size-9 place-items-center rounded-full border border-line text-ink-2" aria-label={t('calendar.prevMonth')}>
|
||||
<ChevronLeft size={18} />
|
||||
</button>
|
||||
<span className="text-lg font-bold capitalize">{month.toLocaleDateString(locale(), { month: 'long', year: 'numeric' })}</span>
|
||||
<span className="text-lg font-bold capitalize">{dateFormat({ month: 'long', year: 'numeric' }).format(month)}</span>
|
||||
<button onClick={() => changeMonth(1)} className="grid size-9 place-items-center rounded-full border border-line text-ink-2" aria-label={t('calendar.nextMonth')}>
|
||||
<ChevronRight size={18} />
|
||||
</button>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Check, Loader2, Lock } from 'lucide-react'
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { locale, t } from '../i18n'
|
||||
import { dateFormat, t } from '../i18n'
|
||||
import { cachedSeasonEpisodes, episodeWindow, getTmdbSeasonEpisodes, preloadImages, type EpisodeInfo } from '../lib/catalogApi'
|
||||
import { episodeCap, episodesBeforeSeason, seasonPosition } from '../lib/franchise'
|
||||
import { tmdbSized } from '../lib/tmdbImage'
|
||||
import { tmdbSized, imgCors } from '../lib/tmdbImage'
|
||||
import { cx, todayISO } from '../lib/utils'
|
||||
import { useMedia } from '../store'
|
||||
import type { MediaInput } from '../types'
|
||||
@@ -72,7 +72,8 @@ export default function EpisodeList({ form, aired, onChange, fallbackImage }: Pr
|
||||
|
||||
// Les infos TMDB complètent la liste ; sans elles (AniList, hors-ligne), on numérote simplement
|
||||
const count = Math.max(size, seasons ? 0 : (episodes?.length ?? 0))
|
||||
const rows: EpisodeInfo[] = Array.from({ length: count }, (_, k) => episodes?.find((e) => e.number === k + 1) ?? { number: k + 1 })
|
||||
const byNumber = new Map(episodes?.map((e) => [e.number, e]))
|
||||
const rows: EpisodeInfo[] = Array.from({ length: count }, (_, k) => byNumber.get(k + 1) ?? { number: k + 1 })
|
||||
const watchedHere = Math.max(0, Math.min(count, form.episodesWatched - before))
|
||||
// Épisodes visibles à l'ouverture (autour du prochain à voir) : images demandées tout de suite
|
||||
const visible = new Set(episodeWindow(rows, watchedHere + 1).map((e) => e.number))
|
||||
@@ -95,7 +96,7 @@ export default function EpisodeList({ form, aired, onChange, fallbackImage }: Pr
|
||||
onChange(Math.max(0, next), seasons ? viewSeason : undefined)
|
||||
}
|
||||
|
||||
const fmtDate = (d: string) => new Date(`${d}T12:00:00`).toLocaleDateString(locale(), { day: 'numeric', month: 'short', year: d.slice(0, 4) === today.slice(0, 4) ? undefined : 'numeric' })
|
||||
const fmtDate = (d: string) => dateFormat(d.slice(0, 4) === today.slice(0, 4) ? { day: 'numeric', month: 'short' } : { day: 'numeric', month: 'short', year: 'numeric' }).format(new Date(`${d}T12:00:00`))
|
||||
|
||||
if (!count) return null
|
||||
|
||||
@@ -124,7 +125,7 @@ export default function EpisodeList({ form, aired, onChange, fallbackImage }: Pr
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div ref={listRef} className="max-h-[26rem] space-y-1 overflow-y-auto lg:max-h-[60vh] overscroll-contain pe-1">
|
||||
<div ref={listRef} className="max-h-[26rem] space-y-1 overflow-y-auto lg:max-h-[60vh] pe-1">
|
||||
{rows.map((e) => {
|
||||
const seen = e.number <= watchedHere
|
||||
// Pas encore sorti : date à venir (TMDB), ou au-delà des épisodes diffusés
|
||||
@@ -139,16 +140,16 @@ export default function EpisodeList({ form, aired, onChange, fallbackImage }: Pr
|
||||
onClick={() => toggle(e.number)}
|
||||
disabled={locked}
|
||||
aria-pressed={seen}
|
||||
className={cx('flex w-full items-center gap-3 rounded-xl p-1.5 text-start transition-colors', locked ? 'cursor-not-allowed' : 'active:bg-surface-2', upcoming && 'opacity-50')}
|
||||
className={cx('ep-row flex w-full items-center gap-3 rounded-xl p-1.5 text-start transition-colors', locked ? 'cursor-not-allowed' : 'active:bg-surface-2', upcoming && 'opacity-50')}
|
||||
>
|
||||
<span className="relative aspect-video w-28 shrink-0 overflow-hidden rounded-lg border border-line bg-surface-2">
|
||||
{e.still ? (
|
||||
<img src={e.still} alt="" loading={visible.has(e.number) ? 'eager' : 'lazy'} decoding="async" className="size-full object-cover" />
|
||||
<img src={e.still} crossOrigin={imgCors(e.still)} alt="" loading={visible.has(e.number) ? 'eager' : 'lazy'} decoding="async" className="size-full object-cover" />
|
||||
) : fallbackImage ? (
|
||||
// Pas d'image pour cet épisode : celle de la série, assombrie, avec le numéro par-dessus
|
||||
<>
|
||||
<img src={tmdbSized(fallbackImage, 'w300')} alt="" loading="lazy" className="size-full object-cover brightness-50" />
|
||||
<span className="absolute inset-0 grid place-items-center text-base font-bold text-white">{e.number}</span>
|
||||
<img src={tmdbSized(fallbackImage, 'w300')} crossOrigin={imgCors(tmdbSized(fallbackImage, 'w300'))} alt="" loading="lazy" decoding="async" className="size-full object-cover" />
|
||||
<span className="absolute inset-0 grid place-items-center bg-black/50 text-base font-bold text-white">{e.number}</span>
|
||||
</>
|
||||
) : (
|
||||
<span className="grid size-full place-items-center text-sm font-semibold text-ink-3">{e.number}</span>
|
||||
|
||||
+75
-19
@@ -1,15 +1,15 @@
|
||||
import type { Completion } from '../lib/seasons'
|
||||
import { Check, Info, Plus } from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { TYPE_BY_VALUE } from '../lib/constants'
|
||||
import { canWatchMore, nextAirDate } from '../lib/airing'
|
||||
import { episodeCap, seasonPosition } from '../lib/franchise'
|
||||
import { progressView } from '../lib/rewatch'
|
||||
import { genreLabel } from '../lib/genres'
|
||||
import { backdropSrcSet, tmdbSized } from '../lib/tmdbImage'
|
||||
import { backdropSrcSet, tmdbSized, imgCors } from '../lib/tmdbImage'
|
||||
import { cx, formatDate } from '../lib/utils'
|
||||
import { useMedia } from '../store'
|
||||
import { useMediaActions } from '../store'
|
||||
import { useToast } from './Toast'
|
||||
import { FilmStrip } from './ui'
|
||||
import type { MediaItem } from '../types'
|
||||
@@ -46,7 +46,7 @@ function stripProgress(item: MediaItem): { done: number; total: number } | undef
|
||||
|
||||
/** +1 depuis l'accueil : saison (ou série) finie → on ouvre la fiche sur la note ; revisionnage fini → petit message. */
|
||||
function usePlusOne(onOpen: (item: MediaItem, focus?: Completion) => void) {
|
||||
const { incrementEpisode } = useMedia()
|
||||
const { incrementEpisode } = useMediaActions()
|
||||
const toast = useToast()
|
||||
return (item: MediaItem) => {
|
||||
const cap = episodeCap(item)
|
||||
@@ -64,30 +64,74 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
|
||||
const plusOne = usePlusOne(onOpen)
|
||||
// On retient le titre affiché (et pas sa position) : la liste se réordonne quand on avance un épisode
|
||||
const [currentId, setCurrentId] = useState<string>()
|
||||
// Titre affiché juste avant : son image reste le temps du fondu
|
||||
const [previousId, setPreviousId] = useState<string>()
|
||||
const [pausedAt, setPausedAt] = useState(0)
|
||||
const touchX = useRef<number | null>(null)
|
||||
const section = useRef<HTMLElement>(null)
|
||||
const images = useRef(new Map<string, HTMLImageElement>())
|
||||
const count = items.length
|
||||
const current = Math.max(0, items.findIndex((i) => i.id === currentId))
|
||||
const item = items[current]
|
||||
const latest = useRef(items)
|
||||
latest.current = items
|
||||
const shownId = useRef(item?.id)
|
||||
shownId.current = item?.id
|
||||
|
||||
// Défilement automatique (toutes les 7 s), relancé après chaque action manuelle
|
||||
const show = (id: string | undefined) => {
|
||||
setPreviousId(shownId.current)
|
||||
setCurrentId(id)
|
||||
}
|
||||
|
||||
// Défilement automatique (toutes les 7 s), relancé après chaque action manuelle.
|
||||
// Pas de défilement si la bannière n'est pas à l'écran, ni si l'appareil demande moins d'animations.
|
||||
useEffect(() => {
|
||||
if (count < 2) return
|
||||
if (count < 2 || matchMedia('(prefers-reduced-motion: reduce)').matches) return
|
||||
let onScreen = true
|
||||
const io = new IntersectionObserver(([e]) => (onScreen = e.isIntersecting))
|
||||
if (section.current) io.observe(section.current)
|
||||
let cancelled = false
|
||||
const timer = setInterval(() => {
|
||||
if (document.visibilityState !== 'visible') return
|
||||
setCurrentId((id) => {
|
||||
const list = latest.current
|
||||
const k = Math.max(0, list.findIndex((i) => i.id === id))
|
||||
return list[(k + 1) % list.length]?.id
|
||||
if (document.visibilityState !== 'visible' || !onScreen) return
|
||||
const list = latest.current
|
||||
const k = Math.max(0, list.findIndex((i) => i.id === shownId.current))
|
||||
const nextId = list[(k + 1) % list.length]?.id
|
||||
// L'image suivante est décodée avant d'être montrée (pas d'image à moitié affichée)
|
||||
const img = nextId ? images.current.get(nextId) : undefined
|
||||
void (img ? img.decode().catch(() => {}) : Promise.resolve()).then(() => {
|
||||
if (!cancelled) show(nextId)
|
||||
})
|
||||
}, 7000)
|
||||
return () => clearInterval(timer)
|
||||
return () => {
|
||||
cancelled = true
|
||||
clearInterval(timer)
|
||||
io.disconnect()
|
||||
}
|
||||
}, [count, pausedAt])
|
||||
|
||||
// Un titre sur deux lignes faisait sauter tout le bas de la bannière au défilement : si l'un des titres
|
||||
// en a besoin, la place de deux lignes est réservée pour tous (sinon, pas d'espace vide sous un titre court)
|
||||
const titleRef = useRef<HTMLHeadingElement>(null)
|
||||
const [twoLines, setTwoLines] = useState(false)
|
||||
const titles = items.map((i) => i.title).join('\n')
|
||||
useLayoutEffect(() => {
|
||||
const h = titleRef.current
|
||||
const ctx = h && document.createElement('canvas').getContext('2d')
|
||||
if (!h || !ctx) return
|
||||
const measure = () => {
|
||||
const cs = getComputedStyle(h)
|
||||
ctx.font = `${cs.fontWeight} ${cs.fontSize} ${cs.fontFamily}`
|
||||
setTwoLines(titles.split('\n').some((title) => ctx.measureText(title).width > h.clientWidth))
|
||||
}
|
||||
measure()
|
||||
void document.fonts?.ready.then(measure)
|
||||
const ro = new ResizeObserver(measure)
|
||||
ro.observe(h)
|
||||
return () => ro.disconnect()
|
||||
}, [titles])
|
||||
|
||||
const go = (k: number) => {
|
||||
setCurrentId(items[((k % count) + count) % count]?.id)
|
||||
show(items[((k % count) + count) % count]?.id)
|
||||
setPausedAt(Date.now())
|
||||
}
|
||||
|
||||
@@ -100,9 +144,13 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
|
||||
|
||||
return (
|
||||
<section
|
||||
ref={section}
|
||||
className="lg:grid lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)] lg:gap-8"
|
||||
aria-roledescription="carousel"
|
||||
onTouchStart={(e) => (touchX.current = e.touches[0].clientX)}
|
||||
onTouchStart={(e) => {
|
||||
touchX.current = e.touches[0].clientX
|
||||
setPausedAt(Date.now()) // pas de défilement automatique sous le doigt
|
||||
}}
|
||||
onTouchEnd={(e) => {
|
||||
const start = touchX.current
|
||||
touchX.current = null
|
||||
@@ -114,14 +162,22 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
|
||||
<button {...prefetchAttrs(item)} onClick={() => onOpen(item)} className="relative block aspect-video w-full overflow-hidden bg-surface-2 lg:aspect-auto lg:h-full lg:min-h-[22rem]" aria-label={t('card.open', { title: item.title })}>
|
||||
{items.map((it, k) => {
|
||||
const image = it.backdrop ?? it.poster
|
||||
return image ? (
|
||||
// Seules l'image affichée, la suivante (préparée) et la précédente (fondu) sont chargées
|
||||
const kept = k === current || k === (current + 1) % count || it.id === previousId
|
||||
return image && kept ? (
|
||||
<img
|
||||
key={it.id}
|
||||
ref={(el) => {
|
||||
if (el) images.current.set(it.id, el)
|
||||
else images.current.delete(it.id)
|
||||
}}
|
||||
src={it.backdrop ? tmdbSized(image, 'w1280') : image}
|
||||
crossOrigin={imgCors(it.backdrop ? tmdbSized(image, 'w1280') : image)}
|
||||
srcSet={it.backdrop ? backdropSrcSet(image) : undefined}
|
||||
sizes="(min-width: 64rem) 60vw, 100vw"
|
||||
alt=""
|
||||
loading={k === 0 ? 'eager' : 'lazy'}
|
||||
decoding={k === current ? 'auto' : 'async'}
|
||||
fetchPriority={k === current ? 'high' : 'low'}
|
||||
className={cx(
|
||||
'absolute inset-0 size-full object-cover transition-opacity duration-500 motion-reduce:transition-none',
|
||||
!it.backdrop && 'scale-110 blur-md',
|
||||
@@ -138,7 +194,7 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
|
||||
<span key={m}>{m}</span>
|
||||
))}
|
||||
</p>
|
||||
<h2 className="mt-1.5 line-clamp-2 text-[1.9rem] leading-[1.08] lg:text-[2.5rem]">{item.title}</h2>
|
||||
<h2 ref={titleRef} className={cx('mt-1.5 line-clamp-2 text-[1.9rem] leading-[1.08] lg:text-[2.5rem]', twoLines && 'min-h-[2.16em]')}>{item.title}</h2>
|
||||
{progress && (
|
||||
<div className="mt-4">
|
||||
<div className="flex items-baseline justify-between gap-3 text-sm text-ink-2">
|
||||
@@ -179,7 +235,7 @@ export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen
|
||||
aria-label={it.title}
|
||||
aria-current={k === current}
|
||||
>
|
||||
<span className={cx('block h-[3px] rounded-[1px] transition-all motion-reduce:transition-none', k === current ? 'w-6 bg-ink' : 'w-3 bg-line-strong')} />
|
||||
<span className={cx('block h-[3px] rounded-[1px] transition-colors motion-reduce:transition-none', k === current ? 'w-6 bg-ink' : 'w-3 bg-line-strong')} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
@@ -198,7 +254,7 @@ export function ContinueCard({ item, onOpen }: { item: MediaItem; onOpen: (item:
|
||||
return (
|
||||
<article className="flex h-[5.5rem] w-72 shrink-0 overflow-hidden rounded-md border border-line bg-surface">
|
||||
<button {...prefetchAttrs(item)} onClick={() => onOpen(item)} className="flex min-w-0 flex-1 items-stretch text-start" aria-label={t('card.open', { title: item.title })}>
|
||||
<span className="block w-[3.6rem] shrink-0 bg-surface-2">{image && <img src={image} alt="" loading="lazy" className="size-full object-cover" />}</span>
|
||||
<span className="block w-[3.6rem] shrink-0 bg-surface-2">{image && <img src={image} crossOrigin={imgCors(image)} alt="" loading="lazy" decoding="async" className="size-full object-cover" />}</span>
|
||||
<span className="flex min-w-0 flex-1 flex-col justify-center px-3">
|
||||
<span className="block truncate font-bold text-base leading-tight">{item.title}</span>
|
||||
<span className="mt-0.5 block truncate text-xs text-ink-3">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { locale, t } from '../i18n'
|
||||
import { dateFormat, locale, t } from '../i18n'
|
||||
import { Star } from 'lucide-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { oneViewMinutes, rewatchMinutes, watchMinutes } from '../lib/stats'
|
||||
@@ -74,7 +74,7 @@ export default function JournalView({ onOpen }: { onOpen: (item: MediaItem) => v
|
||||
</div>
|
||||
|
||||
{months.slice(0, shown).map(([key, list]) => {
|
||||
const label = new Date(key + '-15T12:00:00').toLocaleDateString(locale(), { month: 'long', year: 'numeric' })
|
||||
const label = dateFormat({ month: 'long', year: 'numeric' }).format(new Date(key + '-15T12:00:00'))
|
||||
const minutes = list.reduce((s, e) => s + e.minutes, 0)
|
||||
const finished = list.filter((e) => e.kind === 'fini' || e.kind === 'revu').length
|
||||
return (
|
||||
@@ -94,7 +94,7 @@ export default function JournalView({ onOpen }: { onOpen: (item: MediaItem) => v
|
||||
<button {...prefetchAttrs(e.item)} onClick={() => onOpen(e.item)} className="flex w-full items-center gap-3 py-2.5 text-start">
|
||||
<span className="w-9 shrink-0 text-center">
|
||||
<span className="block text-xl font-bold leading-none tabular-nums">{d.getDate()}</span>
|
||||
<span className="block text-[10px] text-ink-3">{d.toLocaleDateString(locale(), { weekday: 'short' }).replace('.', '')}</span>
|
||||
<span className="block text-[10px] text-ink-3">{dateFormat({ weekday: 'short' }).format(d).replace('.', '')}</span>
|
||||
</span>
|
||||
<div className="w-10 shrink-0">
|
||||
<Poster src={e.item.poster} title={e.item.title} />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Check, Loader2, Plus } from 'lucide-react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { getAniListById, releaseToResult, type GlobalRelease, type SearchResult } from '../lib/catalogApi'
|
||||
import { cachedMonth, loadMonth, RELEASE_CATEGORIES } from '../lib/globalReleases'
|
||||
@@ -42,21 +42,31 @@ export default function LatestReleases({ onOpenSeed }: { onOpenSeed: (seed: Sear
|
||||
const [busy, setBusy] = useState<string>()
|
||||
const [added, setAdded] = useState<Set<string>>(new Set())
|
||||
|
||||
// Mise à jour en arrière-plan (cache de 12 h), un peu après l'affichage de l'accueil
|
||||
// Mise à jour (cache de 12 h) seulement quand la rangée approche de l'écran : elle est tout en bas de
|
||||
// l'accueil et demande plusieurs centaines de requêtes, inutiles si l'on ne descend pas jusque-là
|
||||
const zone = useRef<HTMLDivElement>(null)
|
||||
const [near, setNear] = useState(false)
|
||||
useEffect(() => {
|
||||
if (!navigator.onLine) return
|
||||
const el = zone.current
|
||||
if (near || !el) return
|
||||
const io = new IntersectionObserver(([e]) => e?.isIntersecting && setNear(true), { rootMargin: '800px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [near])
|
||||
useEffect(() => {
|
||||
if (!near || !navigator.onLine) return
|
||||
let alive = true
|
||||
const cats = RELEASE_CATEGORIES.map((c) => c.value)
|
||||
const id = window.setTimeout(() => {
|
||||
void Promise.all(months().map((m) => loadMonth(m, cats, settings.tmdbKey)))
|
||||
.then((res) => alive && setAll(res.flatMap((r) => r.releases)))
|
||||
.catch(() => {})
|
||||
}, 1200)
|
||||
}, 300)
|
||||
return () => {
|
||||
alive = false
|
||||
window.clearTimeout(id)
|
||||
}
|
||||
}, [settings.tmdbKey])
|
||||
}, [near, settings.tmdbKey])
|
||||
|
||||
const owned = useMemo(() => new Set(items.map((i) => i.externalId).filter((x): x is string => !!x)), [items])
|
||||
const ownedTitles = useMemo(
|
||||
@@ -70,7 +80,6 @@ export default function LatestReleases({ onOpenSeed }: { onOpenSeed: (seed: Sear
|
||||
return [...fresh, ...keep.filter((r) => !fresh.some((f) => f.externalId === r.externalId))].sort((a, b) => b.date.localeCompare(a.date))
|
||||
}, [all, owned, ownedTitles, added])
|
||||
|
||||
if (!list.length) return null
|
||||
|
||||
const open = async (r: GlobalRelease) => {
|
||||
const seed = r.externalId.startsWith('anilist:') ? await getAniListById(r.externalId).catch(() => null) : releaseToResult(r)
|
||||
@@ -89,8 +98,10 @@ export default function LatestReleases({ onOpenSeed }: { onOpenSeed: (seed: Sear
|
||||
}
|
||||
}
|
||||
|
||||
// Toujours le même repère (même vide), pour que l'observation ne se perde pas
|
||||
if (!list.length) return <div ref={zone} className="h-px" aria-hidden="true" />
|
||||
return (
|
||||
<>
|
||||
<div ref={zone}>
|
||||
<SectionTitle>{t('home.latestReleases')}</SectionTitle>
|
||||
<div className="no-scrollbar -mx-4 flex gap-3 overflow-x-auto px-4 pb-1">
|
||||
{list.map((r) => {
|
||||
@@ -118,6 +129,6 @@ export default function LatestReleases({ onOpenSeed }: { onOpenSeed: (seed: Sear
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { locale, t } from '../i18n'
|
||||
import { imgCors } from '../lib/tmdbImage'
|
||||
import { ArrowLeft, Check, Pencil, Plus, Search, Trash2 } from 'lucide-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { cx, normalizeText } from '../lib/utils'
|
||||
@@ -20,7 +21,7 @@ function Mosaic({ items }: { items: MediaItem[] }) {
|
||||
<div className="grid grid-cols-2 gap-0.5 overflow-hidden rounded-xl border border-line bg-surface-2">
|
||||
{cells.map((item, i) =>
|
||||
item?.poster ? (
|
||||
<img key={i} src={item.poster} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
|
||||
<img key={i} src={item.poster} crossOrigin={imgCors(item.poster)} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
|
||||
) : (
|
||||
<div key={i} className="aspect-[2/3] w-full bg-surface-2" />
|
||||
),
|
||||
|
||||
@@ -5,7 +5,7 @@ import { TYPE_BY_VALUE } from '../lib/constants'
|
||||
import { canWatchMore } from '../lib/airing'
|
||||
import { episodeCap, seasonPosition } from '../lib/franchise'
|
||||
import { progressView } from '../lib/rewatch'
|
||||
import { useMedia } from '../store'
|
||||
import { useMediaActions } from '../store'
|
||||
import type { MediaItem } from '../types'
|
||||
import { StatusPill, TypeBadge } from './Badges'
|
||||
import Poster from './Poster'
|
||||
@@ -38,11 +38,11 @@ function Progress({ item }: { item: MediaItem }) {
|
||||
|
||||
/**
|
||||
* Carte verticale (grille du catalogue).
|
||||
* Mémorisée : taper dans la recherche ou cocher une fiche ne redessine plus toute la grille
|
||||
* (elle se redessine quand même si la bibliothèque ou les réglages changent, via useMedia).
|
||||
* Mémorisée : taper dans la recherche, cocher une fiche ou une synchro sans changement ne redessine
|
||||
* plus toute la grille (seules les cartes dont la fiche a changé se redessinent).
|
||||
*/
|
||||
export const MediaCard = memo(function MediaCard({ item, onOpen }: { item: MediaItem; onOpen: (item: MediaItem) => void }) {
|
||||
const { incrementEpisode } = useMedia()
|
||||
const { incrementEpisode } = useMediaActions()
|
||||
// Revisionnage en cours : la progression montrée est celle du revisionnage
|
||||
const view = progressView(item)
|
||||
const canIncrement =
|
||||
@@ -53,7 +53,7 @@ export const MediaCard = memo(function MediaCard({ item, onOpen }: { item: Media
|
||||
return (
|
||||
<article>
|
||||
<div className="relative">
|
||||
<button {...prefetchAttrs(item)} onClick={() => onOpen(item)} className="block w-full" aria-label={t('card.open', { title: item.title })}>
|
||||
<button {...prefetchAttrs(item)} onClick={() => onOpen(item)} className="block w-full transition-opacity active:opacity-80 motion-reduce:transition-none" aria-label={t('card.open', { title: item.title })}>
|
||||
<Poster src={item.poster} title={item.title} />
|
||||
</button>
|
||||
<TypeBadge item={item} className="pointer-events-none absolute start-2 top-2 border-transparent bg-bg/85" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { imgCors } from '../lib/tmdbImage'
|
||||
import { cx } from '../lib/utils'
|
||||
|
||||
/** Affiche du média, ou une vignette sobre (aplat + initiale en serif) si aucune image. */
|
||||
@@ -9,6 +10,7 @@ export default function Poster({ src, title, className }: { src?: string; title:
|
||||
return (
|
||||
<img
|
||||
src={src}
|
||||
crossOrigin={imgCors(src)}
|
||||
alt={title}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function SharePreview({ blob, filename, title, onClose }: Props)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="sheet-in fixed inset-0 z-[60] flex flex-col bg-bg/95 backdrop-blur-sm" role="dialog" aria-modal="true" aria-label={t('share.previewLabel')}>
|
||||
<div className="sheet-in fixed inset-0 z-[60] flex flex-col bg-bg" role="dialog" aria-modal="true" aria-label={t('share.previewLabel')}>
|
||||
<div className="safe-top flex items-center justify-between px-3 py-2.5">
|
||||
<button onClick={onClose} className="grid size-10 place-items-center rounded-full text-ink-2" aria-label={t('common.close')}>
|
||||
<X size={22} />
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Check, CloudOff, RefreshCw, X } from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useMedia } from '../store'
|
||||
import { useMedia, useSyncStatus } from '../store'
|
||||
|
||||
function useOnline(): boolean {
|
||||
const [online, setOnline] = useState(() => navigator.onLine)
|
||||
@@ -25,14 +25,15 @@ type Kind = 'offline' | 'offline-local' | 'pending' | 'synced'
|
||||
* Petite pastille discrète : hors-ligne, ou modifications pas encore envoyées au compte.
|
||||
* Mobile : juste au-dessus de la barre de navigation ; ordinateur : en bas de la barre latérale.
|
||||
* Elle disparaît une fois tout synchronisé (après un bref « Synchronisé »).
|
||||
* L'état vient du moteur de synchro (useMedia().account.sync) : rien n'est recalculé ici.
|
||||
* L'état vient du moteur de synchro (useSyncStatus) : rien n'est recalculé ici.
|
||||
*/
|
||||
export default function SyncIndicator() {
|
||||
const { account } = useMedia()
|
||||
const sync = useSyncStatus()
|
||||
const online = useOnline()
|
||||
const pending = account?.sync.pending ?? 0
|
||||
const syncing = account?.sync.state === 'syncing'
|
||||
const failed = account?.sync.state === 'error'
|
||||
const pending = sync?.pending ?? 0
|
||||
const syncing = sync?.state === 'syncing'
|
||||
const failed = sync?.state === 'error'
|
||||
|
||||
// Une modification part normalement en 1-2 s : on ne signale l'attente que si elle dure
|
||||
const [slow, setSlow] = useState(false)
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { t } from '../../i18n'
|
||||
import { Check } from 'lucide-react'
|
||||
import { useEffect, useRef, type ReactNode } from 'react'
|
||||
import { memo, useEffect, useRef } from 'react'
|
||||
import { cx } from '../../lib/utils'
|
||||
import type { MediaItem } from '../../types'
|
||||
import { MediaCard } from '../MediaCard'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
item: MediaItem
|
||||
onOpen: (item: MediaItem) => void
|
||||
selecting: boolean
|
||||
selected: boolean
|
||||
onToggle: () => void
|
||||
onToggle: (id: string) => void
|
||||
/** Appui long (téléphone) ou case à cocher (ordinateur) : entre en mode sélection avec ce titre. */
|
||||
onStartSelect: () => void
|
||||
children: ReactNode
|
||||
onStartSelect: (id: string) => void
|
||||
}
|
||||
|
||||
const LONG_PRESS_MS = 450
|
||||
@@ -20,8 +22,10 @@ const LONG_PRESS_MS = 450
|
||||
* - téléphone : appui long sur la carte ;
|
||||
* - ordinateur : case à cocher au survol ;
|
||||
* - en mode sélection, toucher la carte la coche / décoche (au lieu d'ouvrir la fiche).
|
||||
* Mémorisée (avec des fonctions stables) : ouvrir une fiche ou cocher une carte ne redessine pas toute la grille.
|
||||
*/
|
||||
export default function SelectableCard({ title, selecting, selected, onToggle, onStartSelect, children }: Props) {
|
||||
export default memo(function SelectableCard({ item, onOpen, selecting, selected, onToggle, onStartSelect }: Props) {
|
||||
const title = item.title
|
||||
const timer = useRef<ReturnType<typeof setTimeout>>(undefined)
|
||||
const origin = useRef<{ x: number; y: number }>(undefined)
|
||||
const fired = useRef(false)
|
||||
@@ -46,7 +50,7 @@ export default function SelectableCard({ title, selecting, selected, onToggle, o
|
||||
fired.current = true
|
||||
timer.current = undefined
|
||||
navigator.vibrate?.(12)
|
||||
onStartSelect()
|
||||
onStartSelect(item.id)
|
||||
}, LONG_PRESS_MS)
|
||||
}}
|
||||
onPointerMove={(e) => {
|
||||
@@ -69,12 +73,12 @@ export default function SelectableCard({ title, selecting, selected, onToggle, o
|
||||
}
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
<MediaCard item={item} onOpen={onOpen} />
|
||||
|
||||
{selecting ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
onClick={() => onToggle(item.id)}
|
||||
aria-pressed={selected}
|
||||
aria-label={t('select.toggle', { title })}
|
||||
className={cx('absolute -inset-1 z-10 rounded-2xl transition-colors', selected ? 'bg-accent-fill/15 ring-2 ring-accent' : 'active:bg-ink/5')}
|
||||
@@ -92,7 +96,7 @@ export default function SelectableCard({ title, selecting, selected, onToggle, o
|
||||
// Ordinateur : case à cocher au survol (ou au clavier) pour commencer une sélection
|
||||
<button
|
||||
type="button"
|
||||
onClick={onStartSelect}
|
||||
onClick={() => onStartSelect(item.id)}
|
||||
aria-label={t('select.toggle', { title })}
|
||||
className="absolute end-2 top-2 z-10 hidden size-7 place-items-center rounded-full border-2 border-ink/70 bg-bg/85 text-transparent opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 pointer-fine:grid"
|
||||
>
|
||||
@@ -101,4 +105,4 @@ export default function SelectableCard({ title, selecting, selected, onToggle, o
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
@@ -47,7 +47,7 @@ export default function SelectionBar({ selected, onDone }: Props) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="safe-bottom fixed inset-x-0 bottom-0 z-40 border-t border-line bg-bg/95 backdrop-blur-md lg:start-60 lg:bottom-6 lg:mx-auto lg:max-w-xl lg:rounded-2xl lg:border lg:pb-0">
|
||||
<div className="safe-bottom fixed inset-x-0 bottom-0 z-40 border-t border-line bg-bg lg:start-60 lg:bottom-6 lg:mx-auto lg:max-w-xl lg:rounded-2xl lg:border lg:pb-0">
|
||||
<div className="mx-auto grid max-w-2xl grid-cols-4 px-2" role="toolbar" aria-label={t('select.actions')}>
|
||||
<BarButton icon={<CircleDot size={21} />} label={t('select.status')} onClick={() => setPanel('status')} disabled={none} />
|
||||
<BarButton icon={<ListPlus size={21} />} label={t('select.list')} onClick={() => setPanel('list')} disabled={none} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
|
||||
import { imgCors } from '../../lib/tmdbImage'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { useBackToClose } from '../../lib/backNav'
|
||||
@@ -107,7 +108,7 @@ export default function PersonSheet({
|
||||
<div className="flex items-start gap-4 lg:gap-8">
|
||||
<div className="w-28 shrink-0 lg:w-48">
|
||||
{photo ? (
|
||||
<img src={photo} alt={name} className="aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover" />
|
||||
<img src={photo} crossOrigin={imgCors(photo)} alt={name} className="aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<div className="grid aspect-[2/3] w-full place-items-center rounded-xl border border-line bg-surface-2 text-4xl font-bold text-ink-3" aria-hidden="true">
|
||||
{name.charAt(0) || '?'}
|
||||
|
||||
@@ -27,17 +27,27 @@ function append(list: FeedEntry[], page: FeedEntry[]): FeedEntry[] {
|
||||
|
||||
const VERB = { finished: 'feed.finished', rewatched: 'feed.rewatched', rated: 'feed.rated' } as const
|
||||
|
||||
// Dernière première page reçue : revenir sur l'accueil (le fil est redessiné) ne la redemande pas tout de suite
|
||||
// (seulement si mes abonnements n'ont pas changé depuis)
|
||||
let lastPage: { at: number; follow: string; entries: FeedEntry[]; cursor?: string; more: boolean } | undefined
|
||||
const FRESH_MS = 2 * 60_000
|
||||
const fresh = (follow: string) => !!lastPage && lastPage.follow === follow && Date.now() - lastPage.at < FRESH_MS
|
||||
|
||||
/** Accueil : les derniers titres notés par mes abonnements, avec leur avis. */
|
||||
export default function FriendsFeed() {
|
||||
const social = useSocial()
|
||||
const [entries, setEntries] = useState<FeedEntry[]>()
|
||||
const [more, setMore] = useState(false)
|
||||
const followKey = `${social.me?.following ?? ''}`
|
||||
const follow = useRef(followKey)
|
||||
follow.current = followKey
|
||||
const [initial] = useState(() => (fresh(followKey) ? lastPage : undefined))
|
||||
const [entries, setEntries] = useState<FeedEntry[] | undefined>(initial?.entries)
|
||||
const [more, setMore] = useState(initial?.more ?? false)
|
||||
const [loadingMore, setLoadingMore] = useState(false)
|
||||
const [shown, setShown] = useState(6)
|
||||
// Hors-ligne avant le premier chargement : message au lieu d'un chargement sans fin
|
||||
const [offline, setOffline] = useState(false)
|
||||
// Date de la dernière ligne reçue : point de départ de la page suivante
|
||||
const cursor = useRef<string | undefined>(undefined)
|
||||
const cursor = useRef<string | undefined>(initial?.cursor)
|
||||
// Numéro du dernier chargement : une réponse arrivée après un plus récent est ignorée
|
||||
const req = useRef(0)
|
||||
|
||||
@@ -48,8 +58,10 @@ export default function FriendsFeed() {
|
||||
const page = await getFeed()
|
||||
if (id !== req.current) return
|
||||
cursor.current = page.cursor
|
||||
setEntries(append([], page.entries))
|
||||
const list = append([], page.entries)
|
||||
setEntries(list)
|
||||
setMore(page.received >= FEED_PAGE)
|
||||
lastPage = { at: Date.now(), follow: follow.current, entries: list, cursor: page.cursor, more: page.received >= FEED_PAGE }
|
||||
setOffline(false)
|
||||
} catch {
|
||||
if (id !== req.current) return
|
||||
@@ -64,6 +76,7 @@ export default function FriendsFeed() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!social.enabled) return
|
||||
if (fresh(follow.current)) return // reçu il y a moins de 2 min
|
||||
if (navigator.onLine) void load()
|
||||
else setOffline(true)
|
||||
}, [social.enabled, load])
|
||||
@@ -76,10 +89,14 @@ export default function FriendsFeed() {
|
||||
}, [social.enabled, offline, load])
|
||||
// Retour sur l'app : on récupère ce que les abonnements ont ajouté entre-temps
|
||||
useOnResume(() => void load(), social.enabled)
|
||||
// Abonnement / désabonnement : le fil change aussi
|
||||
const followKey = `${social.me?.following ?? ''}`
|
||||
// Abonnement / désabonnement : le fil change aussi (pas à l'arrivée du profil : le fil vient d'être chargé)
|
||||
const knownFollow = useRef<string>(undefined)
|
||||
useEffect(() => {
|
||||
if (social.enabled && followKey && navigator.onLine) void load()
|
||||
if (!followKey) return
|
||||
const before = knownFollow.current
|
||||
knownFollow.current = followKey
|
||||
if (lastPage && !lastPage.follow) lastPage.follow = followKey // fil chargé avant l'arrivée du profil
|
||||
if (before !== undefined && before !== followKey && social.enabled && navigator.onLine) void load()
|
||||
}, [followKey, social.enabled, load])
|
||||
|
||||
if (!social.enabled) return null
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Check, Loader2, LogOut, Pencil, Plus, Search, Trash2, UserPlus, Users, X } from 'lucide-react'
|
||||
import { imgCors } from '../../lib/tmdbImage'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { locale, t } from '../../i18n'
|
||||
import {
|
||||
@@ -42,7 +43,7 @@ function PosterMosaic({ posters }: { posters: string[] }) {
|
||||
<div className="relative grid grid-cols-2 gap-0.5 overflow-hidden rounded-xl border border-line bg-surface-2">
|
||||
{[0, 1, 2, 3].map((i) =>
|
||||
posters[i] ? (
|
||||
<img key={i} src={posters[i]} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
|
||||
<img key={i} src={posters[i]} crossOrigin={imgCors(posters[i])} alt="" loading="lazy" className="aspect-[2/3] w-full object-cover" />
|
||||
) : (
|
||||
<div key={i} className="aspect-[2/3] w-full bg-surface-2" />
|
||||
),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Check, X } from 'lucide-react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { locale, t } from '../../i18n'
|
||||
import { dateFormat, t } from '../../i18n'
|
||||
import { useBackToClose } from '../../lib/backNav'
|
||||
import { useEscape } from '../../lib/escape'
|
||||
import { useScrollLock } from '../../lib/scrollLock'
|
||||
@@ -30,7 +30,7 @@ export default function StatsSettings({ onClose, initialYear }: { onClose: () =>
|
||||
else next.add(key)
|
||||
updateSettings({ statsHiddenMonths: next.size ? [...next].sort() : undefined })
|
||||
}
|
||||
const label = (key: string) => new Date(`${key}-15T12:00:00`).toLocaleDateString(locale(), { month: 'long', year: 'numeric' })
|
||||
const label = (key: string) => dateFormat({ month: 'long', year: 'numeric' }).format(new Date(`${key}-15T12:00:00`))
|
||||
|
||||
return (
|
||||
<div className="sheet sheet-in" role="dialog" aria-modal="true" aria-label={t('stats.settings')}>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Check, Loader2, PenLine, Search, X } from 'lucide-react'
|
||||
import { imgCors } from '../../lib/tmdbImage'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { useBackToClose } from '../../lib/backNav'
|
||||
@@ -100,7 +101,7 @@ export default function AddTitle({
|
||||
<li key={r.externalId}>
|
||||
<button data-prefetch={r.externalId} onClick={() => (mine ? onOpenItem(mine) : onPick(r))} className="flex w-full items-center gap-3 py-3 text-start active:bg-surface lg:border-b lg:border-line">
|
||||
{r.thumb ? (
|
||||
<img src={r.thumb} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
|
||||
<img src={r.thumb} crossOrigin={imgCors(r.thumb)} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<span className="grid h-[5.25rem] w-14 shrink-0 place-items-center rounded-lg border border-line bg-surface-2 font-semibold text-ink-3">{r.title.charAt(0)}</span>
|
||||
)}
|
||||
@@ -128,7 +129,7 @@ export default function AddTitle({
|
||||
<li key={p.id}>
|
||||
<button onClick={() => onOpenPerson(p)} className="flex w-full items-center gap-3 py-2.5 text-start active:bg-surface lg:border-b lg:border-line">
|
||||
{p.photo ? (
|
||||
<img src={p.photo} alt="" loading="lazy" className="size-14 shrink-0 rounded-full border border-line bg-surface-2 object-cover" />
|
||||
<img src={p.photo} crossOrigin={imgCors(p.photo)} alt="" loading="lazy" className="size-14 shrink-0 rounded-full border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<span className="grid size-14 shrink-0 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3">{p.name.charAt(0)}</span>
|
||||
)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Check, Pencil } from 'lucide-react'
|
||||
import { smoothScroll } from '../../lib/motion'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { episodesBeforeSeason } from '../../lib/franchise'
|
||||
@@ -92,7 +93,7 @@ function SeasonRow({
|
||||
|
||||
// Saison qu'on vient de finir : on l'amène à l'écran
|
||||
useEffect(() => {
|
||||
if (highlight) ref.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
if (highlight) ref.current?.scrollIntoView({ behavior: smoothScroll(), block: 'center' })
|
||||
}, [highlight])
|
||||
|
||||
// À l'ouverture de l'éditeur : on repart de l'avis enregistré (il a pu changer depuis, ex. synchro)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { locale, t } from '../../i18n'
|
||||
import { numberFormat, t } from '../../i18n'
|
||||
import { smoothScroll } from '../../lib/motion'
|
||||
import { FilmStrip } from '../ui'
|
||||
import { Bookmark, Check, ChevronDown, Eye, Heart, Loader2, MessagesSquare, Minus, MoreHorizontal, Pencil, Play, Plus, Share2, Trash2, X } from 'lucide-react'
|
||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
@@ -11,7 +12,7 @@ import { useEscape } from '../../lib/escape'
|
||||
import { episodeCap, seasonPosition } from '../../lib/franchise'
|
||||
import { episodesPatch } from '../../lib/progress'
|
||||
import { useScrollLock } from '../../lib/scrollLock'
|
||||
import { backdropSrcSet, tmdbSized } from '../../lib/tmdbImage'
|
||||
import { backdropSrcSet, tmdbSized, imgCors } from '../../lib/tmdbImage'
|
||||
import { cx, formatDate, formatDuration, formatRating, todayISO } from '../../lib/utils'
|
||||
import { GuestError, useMedia } from '../../store'
|
||||
import { allTags, cleanTag } from '../../lib/bulk'
|
||||
@@ -262,7 +263,7 @@ export default function TitleSheet({ item: initial, seed, onClose, onOpenPerson,
|
||||
const [focus, setFocus] = useState<Completion | undefined>(initialFocus)
|
||||
const ratingRef = useRef<HTMLDivElement>(null)
|
||||
useEffect(() => {
|
||||
if (focus && 'final' in focus) ratingRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
if (focus && 'final' in focus) ratingRef.current?.scrollIntoView({ behavior: smoothScroll(), block: 'center' })
|
||||
}, [focus])
|
||||
|
||||
// Revisionnage qui vient de se terminer (dernier épisode coché ici)
|
||||
@@ -384,6 +385,7 @@ export default function TitleSheet({ item: initial, seed, onClose, onOpenPerson,
|
||||
{heroImage ? (
|
||||
<img
|
||||
src={tmdbSized(heroImage, 'w1280')}
|
||||
crossOrigin={imgCors(tmdbSized(heroImage, 'w1280'))}
|
||||
srcSet={backdropSrcSet(heroImage)}
|
||||
sizes="100vw"
|
||||
alt=""
|
||||
@@ -657,7 +659,7 @@ export default function TitleSheet({ item: initial, seed, onClose, onOpenPerson,
|
||||
className="group w-[5.5rem] shrink-0 text-center"
|
||||
>
|
||||
{c.photo ? (
|
||||
<img src={c.photo} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover transition-colors group-hover:border-accent" />
|
||||
<img src={c.photo} crossOrigin={imgCors(c.photo)} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover transition-colors group-hover:border-accent" />
|
||||
) : (
|
||||
<span className="mx-auto grid size-20 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3 transition-colors group-hover:border-accent">{c.name.charAt(0)}</span>
|
||||
)}
|
||||
@@ -798,7 +800,7 @@ function PublicRating({
|
||||
pending?: boolean
|
||||
}) {
|
||||
const max = Math.max(1, ...(distribution ?? []).map((d) => d.amount))
|
||||
const compact = new Intl.NumberFormat(locale(), { notation: 'compact', maximumFractionDigits: 1 })
|
||||
const compact = numberFormat({ notation: 'compact', maximumFractionDigits: 1 })
|
||||
return (
|
||||
<section className="mx-4 mt-6 flex items-end justify-between gap-4 border-b border-line pb-4">
|
||||
<div className="shrink-0">
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ChevronDown, ExternalLink, Globe } from 'lucide-react'
|
||||
import { useMemo, type ReactNode } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import type { TitleExtras } from '../../lib/catalogApi'
|
||||
import { tmdbSized } from '../../lib/tmdbImage'
|
||||
import { tmdbSized, imgCors } from '../../lib/tmdbImage'
|
||||
import { countryName, defaultWatchRegion, OFFER_KINDS, setWatchRegion, useWatchRegion, type StreamLink, type WatchProvider } from '../../lib/watchProviders'
|
||||
|
||||
const JUSTWATCH = 'https://www.justwatch.com'
|
||||
@@ -96,6 +96,7 @@ function ProviderLogo({ provider, href }: { provider: WatchProvider; href?: stri
|
||||
const logo = provider.logo ? (
|
||||
<img
|
||||
src={provider.logo}
|
||||
crossOrigin={imgCors(provider.logo)}
|
||||
srcSet={`${provider.logo} 1x, ${tmdbSized(provider.logo, 'w154')} 2x`}
|
||||
alt={provider.name}
|
||||
title={provider.name}
|
||||
@@ -132,7 +133,7 @@ function StreamLinks({ links }: { links: StreamLink[] }) {
|
||||
>
|
||||
{l.icon ? (
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-full bg-surface-2" style={l.color ? { backgroundColor: l.color } : undefined}>
|
||||
<img src={l.icon} alt="" loading="lazy" className="size-4 object-contain" />
|
||||
<img src={l.icon} crossOrigin={imgCors(l.icon)} alt="" loading="lazy" className="size-4 object-contain" />
|
||||
</span>
|
||||
) : (
|
||||
<span className="grid size-7 shrink-0 place-items-center rounded-full bg-surface-2 text-xs font-semibold text-ink-2" aria-hidden>
|
||||
|
||||
Reference in new issue
Block a user