perf(P6A.T1): lazy-load ImageAnnotator/Whiteboard/WatchTogether/GameModal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-05-16 23:22:52 +02:00
parent c271e95100
commit a4573b315d
+21 -5
View File
@@ -1,6 +1,6 @@
import { parseMessagePayload, pinMessage, unpinMessage } from '@chat-app/shared/chat'; import { parseMessagePayload, pinMessage, unpinMessage } from '@chat-app/shared/chat';
import { extractErrorCode } from '@chat-app/shared/i18n'; import { extractErrorCode } from '@chat-app/shared/i18n';
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'; import { lazy, Suspense, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom'; import { useParams } from 'react-router-dom';
@@ -26,7 +26,9 @@ import {
SpinnerIcon, SpinnerIcon,
XIcon, XIcon,
} from '../components/icons'; } from '../components/icons';
import { ImageAnnotator } from '../components/ImageAnnotator'; const ImageAnnotator = lazy(() =>
import('../components/ImageAnnotator').then((m) => ({ default: m.ImageAnnotator })),
);
import { InCallPanel } from '../components/InCallPanel'; import { InCallPanel } from '../components/InCallPanel';
import { IncomingCallPanel } from '../components/IncomingCallPanel'; import { IncomingCallPanel } from '../components/IncomingCallPanel';
import { CallPreviewPanel } from '../components/CallPreviewPanel'; import { CallPreviewPanel } from '../components/CallPreviewPanel';
@@ -49,9 +51,15 @@ import {
createWatchTogetherPayload, createWatchTogetherPayload,
createGamePayload, createGamePayload,
} from '../lib/conversationFeatures'; } from '../lib/conversationFeatures';
import { WhiteboardModal } from '../components/WhiteboardModal'; const WhiteboardModal = lazy(() =>
import { WatchTogetherModal } from '../components/WatchTogetherModal'; import('../components/WhiteboardModal').then((m) => ({ default: m.WhiteboardModal })),
import { GameModal } from '../components/GameModal'; );
const WatchTogetherModal = lazy(() =>
import('../components/WatchTogetherModal').then((m) => ({ default: m.WatchTogetherModal })),
);
const GameModal = lazy(() =>
import('../components/GameModal').then((m) => ({ default: m.GameModal })),
);
import { createWhiteboard, createWatchSession, parseYouTubeUrl, createGame, type GameType } from '@chat-app/shared/chat'; import { createWhiteboard, createWatchSession, parseYouTubeUrl, createGame, type GameType } from '@chat-app/shared/chat';
import { compressImages } from '../lib/imageCompress'; import { compressImages } from '../lib/imageCompress';
import { ensureInstallId } from '../lib/installId'; import { ensureInstallId } from '../lib/installId';
@@ -1321,6 +1329,7 @@ export function ConversationPage() {
/> />
{annotatingIndex !== null && attachments[annotatingIndex] && ( {annotatingIndex !== null && attachments[annotatingIndex] && (
<Suspense fallback={null}>
<ImageAnnotator <ImageAnnotator
file={attachments[annotatingIndex]!} file={attachments[annotatingIndex]!}
onCancel={() => setAnnotatingIndex(null)} onCancel={() => setAnnotatingIndex(null)}
@@ -1329,27 +1338,34 @@ export function ConversationPage() {
setAnnotatingIndex(null); setAnnotatingIndex(null);
}} }}
/> />
</Suspense>
)} )}
{openWhiteboardId && ( {openWhiteboardId && (
<Suspense fallback={null}>
<WhiteboardModal <WhiteboardModal
whiteboardId={openWhiteboardId} whiteboardId={openWhiteboardId}
onClose={() => setOpenWhiteboardId(null)} onClose={() => setOpenWhiteboardId(null)}
/> />
</Suspense>
)} )}
{openWatchSessionId && ( {openWatchSessionId && (
<Suspense fallback={null}>
<WatchTogetherModal <WatchTogetherModal
sessionId={openWatchSessionId} sessionId={openWatchSessionId}
onClose={() => setOpenWatchSessionId(null)} onClose={() => setOpenWatchSessionId(null)}
/> />
</Suspense>
)} )}
{openGameId && ( {openGameId && (
<Suspense fallback={null}>
<GameModal <GameModal
gameId={openGameId} gameId={openGameId}
onClose={() => setOpenGameId(null)} onClose={() => setOpenGameId(null)}
/> />
</Suspense>
)} )}
{gameDialogOpen && ( {gameDialogOpen && (