From a92e0e7252993883b0dcc2ac0074872ff21e7b3b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 29 Nov 2026 14:52:03 +0000 Subject: [PATCH] =?UTF-8?q?Plus=20l=C3=A9ger=20et=20plus=20rapide=20:=20co?= =?UTF-8?q?mpression=20des=20fichiers,=20fiche=20et=20listes=20charg=C3=A9?= =?UTF-8?q?es=20=C3=A0=20la=20demande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nginx : compression gzip des fichiers de l'app (JS, CSS, JSON, SVG) ; ils partaient bruts (fichier principal 387 Ko envoyés au lieu de ~116 Ko). gzip_http_version 1.0 car le proxy en façade parle HTTP/1.0 - Fiche d'un titre, recherche d'ajout, onglets Journal et Listes, listes partagées : chargés à la demande (préchargés au repos, gardés par le service worker) - « Nouvelle liste » dans son propre fichier (n'embarque plus tout l'onglet Listes) - Fichier principal : 387 → 270 Ko (116 → 85 Ko compressés) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe --- deploy/nginx/site.conf | 11 +++++++ src/App.tsx | 42 ++++++++++++++---------- src/components/ListsView.tsx | 33 +------------------ src/components/NewListForm.tsx | 40 ++++++++++++++++++++++ src/components/library/SelectionBar.tsx | 2 +- src/components/social/SocialProvider.tsx | 4 ++- src/components/title/TitleSheet.tsx | 2 +- src/pages/CatalogPage.tsx | 16 ++++++--- 8 files changed, 92 insertions(+), 58 deletions(-) create mode 100644 src/components/NewListForm.tsx diff --git a/deploy/nginx/site.conf b/deploy/nginx/site.conf index 7e45043..835cbd9 100644 --- a/deploy/nginx/site.conf +++ b/deploy/nginx/site.conf @@ -13,6 +13,17 @@ server { # Adresse inconnue : vraie réponse 404 avec une page dédiée error_page 404 /404.html; + # Compression : sans elle, l'app partait brute (fichier principal 387 Ko au lieu de ~116 Ko, React 223 → 69 Ko). + # Réglée ici, au niveau du site (aucun doublon possible avec la config générale de nginx). + gzip on; + gzip_vary on; + gzip_proxied any; + # Le proxy HTTPS en façade parle à ce serveur en HTTP/1.0 : par défaut, nginx ne compresse alors rien + gzip_http_version 1.0; + gzip_comp_level 6; + gzip_min_length 1024; + gzip_types text/css application/javascript text/javascript application/json application/manifest+json image/svg+xml text/plain; + # nginx ne connaît pas .webmanifest : sans cette ligne, le manifest du PWA est servi en octet-stream include /etc/nginx/mime.types; types { application/manifest+json webmanifest; } diff --git a/src/App.tsx b/src/App.tsx index 644368c..81a182b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,8 +3,6 @@ import { ToastProvider } from './components/Toast' import { lazy, Suspense, useCallback, useEffect, useState } from 'react' import BottomNav, { type Tab } from './components/BottomNav' import SideNav from './components/SideNav' -import AddTitle from './components/title/AddTitle' -import TitleSheet from './components/title/TitleSheet' import HomePage from './pages/HomePage' import CatalogPage from './pages/CatalogPage' import SyncIndicator from './components/SyncIndicator' @@ -15,6 +13,9 @@ import type { Completion } from './lib/seasons' // Écrans moins fréquents : chargés à la demande (démarrage plus léger), puis préchargés quand l'app est au repos const loaders = { + // Fiche d'un titre et recherche pour ajouter : les plus utilisés, préchargés dès que l'app est au repos + TitleSheet: () => import('./components/title/TitleSheet'), + AddTitle: () => import('./components/title/AddTitle'), EditDetails: () => import('./components/title/EditDetails'), PersonSheet: () => import('./components/person/PersonSheet'), Roulette: () => import('./components/Roulette'), @@ -24,6 +25,8 @@ const loaders = { AdminPage: () => import('./pages/AdminPage'), NotFoundPage: () => import('./pages/NotFoundPage'), } +const TitleSheet = lazy(loaders.TitleSheet) +const AddTitle = lazy(loaders.AddTitle) const EditDetails = lazy(loaders.EditDetails) const PersonSheet = lazy(loaders.PersonSheet) const Roulette = lazy(loaders.Roulette) @@ -132,25 +135,28 @@ export default function App() { {adding && ( - setAdding(false)} - onPick={openSeed} - onOpenItem={openItem} - onOpenPerson={openPerson} - onManual={(title) => setManual(title)} - /> + + setAdding(false)} + onPick={openSeed} + onOpenItem={openItem} + onOpenPerson={openPerson} + onManual={(title) => setManual(title)} + /> + )} {layers.map((l) => l.kind === 'title' ? ( - closeLayer(l.uid)} - onOpenPerson={openPerson} - focus={l.item ? l.focus : undefined} - onDone={backHome} - /> + + closeLayer(l.uid)} + onOpenPerson={openPerson} + focus={l.item ? l.focus : undefined} + onDone={backHome} + /> + ) : ( void; autoFocus?: boolean }) { - const { createList } = useMedia() - const [name, setName] = useState('') - // Pas de
ici : ce champ peut vivre à l'intérieur du formulaire d'une fiche - const submit = () => { - if (!name.trim()) return - onCreated?.(createList(name)) - setName('') - } - return ( -
- setName(e.target.value)} - onKeyDown={(e) => { - if (e.key === 'Enter') { - e.preventDefault() - submit() - } - }} - placeholder={t('lists.newListPh')} - autoFocus={autoFocus} - enterKeyHint="done" - /> - -
- ) -} - function ListDetail({ list, onBack, onOpen }: { list: CustomList; onBack: () => void; onOpen: (item: MediaItem) => void }) { const { items, renameList, deleteList, toggleInList } = useMedia() const actions = useLibraryActions() diff --git a/src/components/NewListForm.tsx b/src/components/NewListForm.tsx new file mode 100644 index 0000000..aa31274 --- /dev/null +++ b/src/components/NewListForm.tsx @@ -0,0 +1,40 @@ +import { useState } from 'react' +import { t } from '../i18n' +import { useMedia } from '../store' +import type { CustomList } from '../types' + +/** + * Champ « Nouvelle liste » (onglet Listes, fiche d'un titre, sélection multiple). + * Dans son propre fichier : l'importer n'embarque pas tout l'onglet Listes (chargé à la demande). + */ +export function NewListForm({ onCreated, autoFocus }: { onCreated?: (list: CustomList) => void; autoFocus?: boolean }) { + const { createList } = useMedia() + const [name, setName] = useState('') + // Pas de ici : ce champ peut vivre à l'intérieur du formulaire d'une fiche + const submit = () => { + if (!name.trim()) return + onCreated?.(createList(name)) + setName('') + } + return ( +
+ setName(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault() + submit() + } + }} + placeholder={t('lists.newListPh')} + autoFocus={autoFocus} + enterKeyHint="done" + /> + +
+ ) +} diff --git a/src/components/library/SelectionBar.tsx b/src/components/library/SelectionBar.tsx index 25a8d9d..20b7f23 100644 --- a/src/components/library/SelectionBar.tsx +++ b/src/components/library/SelectionBar.tsx @@ -11,7 +11,7 @@ import { GuestError, useMedia } from '../../store' import type { MediaItem, WatchStatus } from '../../types' import { StatusDot } from '../Badges' import ConfirmDialog from '../ConfirmDialog' -import { NewListForm } from '../ListsView' +import { NewListForm } from '../NewListForm' import { useToast } from '../Toast' import { useLibraryActions } from './useLibraryActions' diff --git a/src/components/social/SocialProvider.tsx b/src/components/social/SocialProvider.tsx index 2ad0f83..bfb68d8 100644 --- a/src/components/social/SocialProvider.tsx +++ b/src/components/social/SocialProvider.tsx @@ -5,7 +5,6 @@ import type { MediaItem } from '../../types' import type { PeekOwner } from './ItemPeek' import { useOnResume } from '../../lib/onResume' import WelcomeProfile, { RANDOM_USERNAME } from './WelcomeProfile' -import { InvitePeople, SharedListSheet } from './SharedLists' import { getAniListById, type SearchResult } from '../../lib/catalogApi' import { TYPE_BY_VALUE } from '../../lib/constants' import type { SharedListItem } from '../../lib/cloud/sharedLists' @@ -47,6 +46,7 @@ const socialLoaders = { ProfileView: () => import('./ProfileView'), TitleReviews: () => import('./TitleReviews'), ItemPeek: () => import('./ItemPeek'), + SharedLists: () => import('./SharedLists'), } const NotificationsSheet = lazy(socialLoaders.NotificationsSheet) const EditProfile = lazy(socialLoaders.EditProfile) @@ -55,6 +55,8 @@ const PeopleSearch = lazy(socialLoaders.PeopleSearch) const ProfileView = lazy(socialLoaders.ProfileView) const TitleReviews = lazy(socialLoaders.TitleReviews) const ItemPeek = lazy(socialLoaders.ItemPeek) +const SharedListSheet = lazy(() => socialLoaders.SharedLists().then((m) => ({ default: m.SharedListSheet }))) +const InvitePeople = lazy(() => socialLoaders.SharedLists().then((m) => ({ default: m.InvitePeople }))) export function preloadSocial() { for (const load of Object.values(socialLoaders)) void load().catch(() => {}) } diff --git a/src/components/title/TitleSheet.tsx b/src/components/title/TitleSheet.tsx index e7ec1ff..4ace810 100644 --- a/src/components/title/TitleSheet.tsx +++ b/src/components/title/TitleSheet.tsx @@ -21,7 +21,7 @@ import type { MediaInput, MediaItem, WatchStatus } from '../../types' import ConfirmDialog from '../ConfirmDialog' import EpisodeList from '../EpisodeList' import { useSocial } from '../social/SocialProvider' -import { NewListForm } from '../ListsView' +import { NewListForm } from '../NewListForm' import Poster from '../Poster' import { RatingInput } from '../Rating' import SharePreview from '../SharePreview' diff --git a/src/pages/CatalogPage.tsx b/src/pages/CatalogPage.tsx index a2b0544..3a7d008 100644 --- a/src/pages/CatalogPage.tsx +++ b/src/pages/CatalogPage.tsx @@ -1,10 +1,8 @@ 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, useRef, useState } from 'react' +import { lazy, Suspense, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react' import { StatusDot } from '../components/Badges' -import JournalView from '../components/JournalView' -import ListsView from '../components/ListsView' import { MediaCard } from '../components/MediaCard' import { EmptyState, PageHeader } from '../components/ui' import { MEDIA_TYPES, STATUSES } from '../lib/constants' @@ -17,6 +15,10 @@ import { useBackToClose } from '../lib/backNav' import { useEscape } from '../lib/escape' import type { MediaItem, MediaType, WatchStatus } from '../types' +// Onglets « Journal » et « Listes » : chargés quand on les ouvre (gardés sur l'appareil par le service worker) +const JournalView = lazy(() => import('../components/JournalView')) +const ListsView = lazy(() => import('../components/ListsView')) + type SortKey = 'recent' | 'rating' | 'title' | 'watched' const SORTS: { value: SortKey; readonly label: string }[] = [ @@ -168,9 +170,13 @@ export default function CatalogPage({ onOpen, onAdd }: Props) { {view === 'journal' ? ( - + + + ) : view === 'lists' ? ( - + + + ) : ( <>