Démarrage plus léger : écrans rares chargés à la demande

- Stats, Réglages, Admin, Roulette, Calendrier, fiche personne, saisie manuelle et écrans sociaux
  (profil, recherche de membres, abonnés, avis, notifications, aperçu) chargés à la demande,
  puis préchargés dès que l'app est au repos : ils s'ouvrent ensuite sans attente
- Carte de partage chargée au moment du partage
- Fichier principal : 784 Ko → 620 Ko
- Noms de fichiers exportés : bobinoo-… au lieu de kino-…

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-11-27 17:40:02 +00:00
1 parent 81c6a447d9
commit 71b1e91947
6 files changed
+95 -44

No files matched your search

+2 -2
View File
@@ -3,7 +3,6 @@ import { t } from '../i18n'
import { Loader2, Plus, Share2 } from 'lucide-react'
import { useState, type CSSProperties } from 'react'
import { TOP_CATEGORIES } from '../lib/constants'
import { renderTopCard, slug } from '../lib/shareCard'
import { cx, formatRating } from '../lib/utils'
import { useMedia } from '../store'
import type { MediaItem, TopCategory } from '../types'
@@ -60,8 +59,9 @@ export default function TopFive({ onOpen }: { onOpen: (item: MediaItem) => void
const share = async () => {
setSharing(true)
try {
const { renderTopCard, slug } = await import('../lib/shareCard')
const blob = await renderTopCard(current.plural, [1, 2, 3, 4, 5].map((r) => byRank.get(r)))
setPreview({ blob, filename: `kino-top5-${slug(current.plural)}.png`, title: t('top.shareTitle', { category: current.plural }) })
setPreview({ blob, filename: `bobinoo-top5-${slug(current.plural)}.png`, title: t('top.shareTitle', { category: current.plural }) })
} finally {
setSharing(false)
}
+34 -13
View File
@@ -1,14 +1,8 @@
import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
import { createContext, lazy, Suspense, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
import { getFollowRequests, getMyProfile, unreadNotifications, type Profile, type ProfileCard } from '../../lib/cloud/social'
import NotificationsSheet from './NotificationsSheet'
import { useMedia } from '../../store'
import type { MediaItem } from '../../types'
import EditProfile from './EditProfile'
import FollowList from './FollowList'
import ItemPeek, { type PeekOwner } from './ItemPeek'
import PeopleSearch from './PeopleSearch'
import ProfileView from './ProfileView'
import TitleReviews from './TitleReviews'
import type { PeekOwner } from './ItemPeek'
import { useOnResume } from '../../lib/onResume'
import WelcomeProfile, { RANDOM_USERNAME } from './WelcomeProfile'
import { InvitePeople, SharedListSheet } from './SharedLists'
@@ -44,6 +38,27 @@ interface SocialApi {
bumpShared: () => void
}
// Écrans sociaux chargés à la demande (préchargés par App au repos via preloadSocial)
const socialLoaders = {
NotificationsSheet: () => import('./NotificationsSheet'),
EditProfile: () => import('./EditProfile'),
FollowList: () => import('./FollowList'),
PeopleSearch: () => import('./PeopleSearch'),
ProfileView: () => import('./ProfileView'),
TitleReviews: () => import('./TitleReviews'),
ItemPeek: () => import('./ItemPeek'),
}
const NotificationsSheet = lazy(socialLoaders.NotificationsSheet)
const EditProfile = lazy(socialLoaders.EditProfile)
const FollowList = lazy(socialLoaders.FollowList)
const PeopleSearch = lazy(socialLoaders.PeopleSearch)
const ProfileView = lazy(socialLoaders.ProfileView)
const TitleReviews = lazy(socialLoaders.TitleReviews)
const ItemPeek = lazy(socialLoaders.ItemPeek)
export function preloadSocial() {
for (const load of Object.values(socialLoaders)) void load().catch(() => {})
}
const SocialContext = createContext<SocialApi>({
enabled: false,
me: null,
@@ -221,8 +236,9 @@ export function SocialProvider({
<SocialContext.Provider value={api}>
{/* Les écrans sociaux sont placés avant l'app : une fiche ouverte depuis un profil passe au-dessus */}
{enabled &&
stack.map((o) =>
o.kind === 'profile' ? (
stack.map((o) => (
<Suspense key={o.uid} fallback={null}>
{o.kind === 'profile' ? (
<ProfileView key={o.uid} username={o.username} onClose={() => close(o.uid)} />
) : o.kind === 'search' ? (
<PeopleSearch key={o.uid} onClose={() => close(o.uid)} />
@@ -238,11 +254,16 @@ export function SocialProvider({
<NotificationsSheet key={o.uid} onClose={() => close(o.uid)} onSeen={() => setUnread(0)} />
) : (
<InvitePeople key={o.uid} listId={o.listId} listName={o.listName} onClose={() => close(o.uid)} />
),
)}
)}
</Suspense>
))}
{children}
{enabled && me && RANDOM_USERNAME.test(me.username) && !welcomeLater && <WelcomeProfile onLater={later} />}
{enabled && peeked && <ItemPeek item={peeked.item} owner={peeked.owner} onClose={() => setPeeked(undefined)} />}
{enabled && peeked && (
<Suspense fallback={null}>
<ItemPeek item={peeked.item} owner={peeked.owner} onClose={() => setPeeked(undefined)} />
</Suspense>
)}
</SocialContext.Provider>
)
}
+3 -2
View File
@@ -13,7 +13,6 @@ import { episodeCap, seasonPosition } from '../../lib/franchise'
import { episodesPatch } from '../../lib/progress'
import { useScrollLock } from '../../lib/scrollLock'
import { backdropSrcSet, tmdbSized } from '../../lib/tmdbImage'
import { renderItemCard, slug } from '../../lib/shareCard'
import { cx, formatDate, formatDuration, formatRating, todayISO } from '../../lib/utils'
import { GuestError, useMedia } from '../../store'
import { allTags, cleanTag } from '../../lib/bulk'
@@ -295,8 +294,10 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
if (settings.tmdbKey && item.externalId?.startsWith('tmdb:') && navigator.onLine) {
credits = await getTmdbCredits(item.externalId, settings.tmdbKey).catch(() => undefined)
}
// Carte de partage : module chargé seulement quand on partage
const { renderItemCard, slug } = await import('../../lib/shareCard')
const blob = await renderItemCard(item, credits)
setPreview({ blob, filename: `kino-${slug(item.title)}.png` })
setPreview({ blob, filename: `bobinoo-${slug(item.title)}.png` })
} catch {
setToast(t('share.err.create'))
} finally {