Fluidité et ménage
- Catalogue : grille affichée par tranches de 60 au fil du défilement (sans revenir en haut quand une fiche change), images décodées en arrière-plan, avatars chargés à la demande - Réglage « couleur d'accent » retiré des réglages, de la synchro et des sauvegardes (n'existait plus) - CLAUDE.md à jour (adresse du site, état au 28 nov.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
8 files changed
+31
-18
No files matched your search
@@ -11,6 +11,7 @@ export default function Poster({ src, title, className }: { src?: string; title:
|
||||
src={src}
|
||||
alt={title}
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
onError={() => setBroken(src)}
|
||||
className={cx('aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover', className)}
|
||||
/>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { cx } from '../../lib/utils'
|
||||
/** Photo de profil ronde, ou initiale sur fond neutre. */
|
||||
export default function Avatar({ url, name, size = 40, className }: { url?: string; name: string; size?: number; className?: string }) {
|
||||
const style = { width: size, height: size }
|
||||
if (url) return <img src={url} alt="" style={style} className={cx('shrink-0 rounded-full border border-line bg-surface-2 object-cover', className)} />
|
||||
if (url) return <img src={url} alt="" loading="lazy" decoding="async" style={style} className={cx('shrink-0 rounded-full border border-line bg-surface-2 object-cover', className)} />
|
||||
return (
|
||||
<span style={{ ...style, fontSize: size * 0.42 }} className={cx('grid shrink-0 place-items-center rounded-full border border-line bg-surface-2 font-bold text-ink-2', className)}>
|
||||
{(name.trim().charAt(0) || '?').toUpperCase()}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { convertLegacyBackup, isLegacyBackup } from './legacyImport'
|
||||
import { cleanThemeMode } from './theme'
|
||||
import {
|
||||
cleanText,
|
||||
isHexColor,
|
||||
isPlainObject,
|
||||
isSafeExternalId,
|
||||
isSafeId,
|
||||
@@ -158,8 +157,6 @@ export function normalizeSettings(raw: unknown): Partial<Settings> | undefined {
|
||||
if (!isPlainObject(raw)) return undefined
|
||||
const out: Partial<Settings> = {}
|
||||
if (Array.isArray(raw.topCategories)) out.topCategories = ALL_TOP_CATEGORIES.filter((c) => (raw.topCategories as unknown[]).includes(c))
|
||||
// Couleur d'accent : plus réglable, gardée seulement pour ne pas casser les sauvegardes et la synchro
|
||||
if (isHexColor(raw.accentColor)) out.accentColor = raw.accentColor.toLowerCase()
|
||||
const themeMode = cleanThemeMode(raw.themeMode)
|
||||
if (themeMode) out.themeMode = themeMode
|
||||
if (Array.isArray(raw.statsHiddenMonths)) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { cloudFetch } from './api'
|
||||
* En cas de conflit, la modification la plus récente gagne (vérifié aussi par la base).
|
||||
*/
|
||||
|
||||
export type SyncedSettings = Pick<Settings, 'topCategories' | 'accentColor' | 'themeMode' | 'statsHiddenMonths'>
|
||||
export type SyncedSettings = Pick<Settings, 'topCategories' | 'themeMode' | 'statsHiddenMonths'>
|
||||
|
||||
export interface SyncHooks {
|
||||
getLists: () => CustomList[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { genreLabel, subtypeLabel } from '../lib/genres'
|
||||
import { locale, t } from '../i18n'
|
||||
import { CheckSquare, Hash, Heart, Search, SlidersHorizontal, X } from 'lucide-react'
|
||||
import { useDeferredValue, useEffect, useMemo, useState } from 'react'
|
||||
import { useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { StatusDot } from '../components/Badges'
|
||||
import JournalView from '../components/JournalView'
|
||||
import ListsView from '../components/ListsView'
|
||||
@@ -31,6 +31,8 @@ interface Props {
|
||||
onAdd: () => void
|
||||
}
|
||||
|
||||
const GRID_STEP = 60
|
||||
|
||||
export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
const { items, lists } = useMedia()
|
||||
const [view, setView] = useState<'titles' | 'journal' | 'lists'>('titles')
|
||||
@@ -120,6 +122,18 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
}
|
||||
|
||||
// Fiches sélectionnées encore présentes (une fiche a pu être supprimée entre-temps)
|
||||
// Grille affichée par tranches : une grande bibliothèque ne dessine pas des centaines de cartes d'un coup
|
||||
const [gridCount, setGridCount] = useState(GRID_STEP)
|
||||
// Retour au début seulement quand la recherche ou les filtres changent (pas quand une fiche bouge : +1, note…)
|
||||
useEffect(() => setGridCount(GRID_STEP), [deferredQuery, types, status, genre, minRating, favOnly, tag, sort])
|
||||
const more = useRef<HTMLDivElement>(null)
|
||||
useEffect(() => {
|
||||
const el = more.current
|
||||
if (!el || gridCount >= results.length) return
|
||||
const io = new IntersectionObserver((e) => e[0]?.isIntersecting && setGridCount((n) => n + GRID_STEP), { rootMargin: '1200px 0px' })
|
||||
io.observe(el)
|
||||
return () => io.disconnect()
|
||||
}, [gridCount, results.length])
|
||||
const selected = useMemo(() => (selection ? items.filter((i) => selection.has(i.id)) : []), [items, selection])
|
||||
const allShownSelected = selecting && results.length > 0 && results.every((i) => selection.has(i.id))
|
||||
|
||||
@@ -314,7 +328,7 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
/>
|
||||
) : (
|
||||
<div className="mt-3 grid grid-cols-2 gap-x-3.5 gap-y-6 sm:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-8">
|
||||
{results.map((item) => (
|
||||
{results.slice(0, gridCount).map((item) => (
|
||||
<SelectableCard
|
||||
key={item.id}
|
||||
title={item.title}
|
||||
@@ -328,6 +342,7 @@ export default function CatalogPage({ onOpen, onAdd }: Props) {
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{gridCount < results.length && <div ref={more} className="h-px" aria-hidden="true" />}
|
||||
{selecting && <SelectionBar selected={selected} onDone={exitSelection} />}
|
||||
</>
|
||||
)}
|
||||
|
||||
+5
-5
@@ -35,7 +35,7 @@ function persistLists(lists: CustomList[]) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
const DEFAULT_SETTINGS: Settings = { topCategories: ALL_TOP_CATEGORIES, accentColor: '#f0a63a', themeMode: 'auto' }
|
||||
const DEFAULT_SETTINGS: Settings = { topCategories: ALL_TOP_CATEGORIES, themeMode: 'auto' }
|
||||
|
||||
/** Relit les réglages en ne gardant que des valeurs valides (le localStorage peut avoir été modifié). */
|
||||
function loadSettings(): Settings {
|
||||
@@ -242,9 +242,9 @@ export function MediaProvider({
|
||||
getLists: () => listsRef.current,
|
||||
applyLists: (next) => setLists(() => next, true),
|
||||
getSettings: () => {
|
||||
const { topCategories, accentColor, themeMode, statsHiddenMonths } = settingsRef.current
|
||||
const { topCategories, themeMode, statsHiddenMonths } = settingsRef.current
|
||||
// Mois masqués : liste vide plutôt qu'absente, sinon « tout réafficher » ne partirait jamais au serveur
|
||||
return { topCategories, accentColor, themeMode, statsHiddenMonths: statsHiddenMonths ?? [] }
|
||||
return { topCategories, themeMode, statsHiddenMonths: statsHiddenMonths ?? [] }
|
||||
},
|
||||
applySettings: (patch) => updateSettingsRef.current(patch, true),
|
||||
itemsChanged: () => void reloadItems().catch(() => {}),
|
||||
@@ -285,7 +285,7 @@ export function MediaProvider({
|
||||
}, [settings.themeMode])
|
||||
|
||||
const updateSettings = useCallback((patch: Partial<Settings>, silent = false) => {
|
||||
if (!silent && syncRef.current && ('topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch || 'statsHiddenMonths' in patch)) syncRef.current.markSettings()
|
||||
if (!silent && syncRef.current && ('topCategories' in patch || 'themeMode' in patch || 'statsHiddenMonths' in patch)) syncRef.current.markSettings()
|
||||
setSettings((prev) => {
|
||||
const next = { ...prev, ...patch }
|
||||
try {
|
||||
@@ -574,7 +574,7 @@ export function MediaProvider({
|
||||
const current = settingsRef.current
|
||||
const merged = oldSettings
|
||||
const patch: Partial<Settings> = {}
|
||||
for (const k of ['topCategories', 'accentColor', 'themeMode'] as const) {
|
||||
for (const k of ['topCategories', 'themeMode'] as const) {
|
||||
if (mine[k] === undefined && merged[k] !== undefined) Object.assign(patch, { [k]: merged[k] })
|
||||
}
|
||||
if (oldSettings.statsHiddenMonths?.length) patch.statsHiddenMonths = [...new Set([...(current.statsHiddenMonths ?? []), ...oldSettings.statsHiddenMonths])].sort()
|
||||
|
||||
@@ -105,8 +105,6 @@ export interface Settings {
|
||||
tmdbKey?: string
|
||||
/** Catégories de Top 5 affichées sur l'accueil (toutes par défaut). */
|
||||
topCategories: TopCategory[]
|
||||
/** Ancienne couleur d'accent (plus réglable), gardée pour la compatibilité des sauvegardes et de la synchro. */
|
||||
accentColor: string
|
||||
/** Apparence (clair ou sombre). « auto » suit le navigateur. */
|
||||
themeMode: ThemeMode
|
||||
/** Mois masqués dans la courbe des stats (AAAA-MM), ex. le mois où j'ai tout ajouté d'un coup. */
|
||||
|
||||
Reference in new issue
Block a user