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:
6 files changed
+95
-44
No files matched your search
@@ -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>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user