Skip to content

Commit

Permalink
chore(mobile): don't lazy main pages
Browse files Browse the repository at this point in the history
  • Loading branch information
CatsJuice authored and pengx17 committed Aug 27, 2024
1 parent 0266c44 commit ce18569
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/core/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Component = ({
}
})
.catch(err => console.error('Failed to create cloud workspace', err));
}, [jumpToPage, openPage, workspacesService]);
}, [defaultIndexRoute, jumpToPage, openPage, workspacesService]);

useLayoutEffect(() => {
if (!navigating) {
Expand Down
15 changes: 13 additions & 2 deletions packages/frontend/mobile/src/pages/workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
useMemo,
useState,
} from 'react';
import { matchPath, useLocation, useParams } from 'react-router-dom';
import {
matchPath,
type RouteObject,
useLocation,
useParams,
} from 'react-router-dom';

import { viewRoutes } from '../../router';
import { WorkspaceLayout } from './layout';
Expand All @@ -33,7 +38,13 @@ const MobileRouteContainer = ({ route }: { route: Route }) => {
);
};

const warpedRoutes = viewRoutes.map(({ path, lazy }) => {
const warpedRoutes = viewRoutes.map((originalRoute: RouteObject) => {
if (originalRoute.Component || !originalRoute.lazy) {
return originalRoute;
}

const { path, lazy } = originalRoute;

const Component = reactLazy(() =>
lazy().then(m => ({
default: m.Component as React.ComponentType,
Expand Down
10 changes: 7 additions & 3 deletions packages/frontend/mobile/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
redirect,
} from 'react-router-dom';

import { Component as All } from './pages/workspace/all';
import { Component as Home } from './pages/workspace/home';
import { Component as Search } from './pages/workspace/search';

export const topLevelRoutes = [
{
element: <RootRouter />,
Expand Down Expand Up @@ -51,15 +55,15 @@ export const topLevelRoutes = [
export const viewRoutes = [
{
path: '/home',
lazy: () => import('./pages/workspace/home'),
Component: Home,
},
{
path: '/search',
lazy: () => import('./pages/workspace/search'),
Component: Search,
},
{
path: '/all',
lazy: () => import('./pages/workspace/all'),
Component: All,
},
{
path: '/collection',
Expand Down
45 changes: 1 addition & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3625,23 +3625,7 @@ __metadata:
languageName: node
linkType: hard

"@blocksuite/icons@npm:2.1.64, @blocksuite/icons@npm:^2.1.62":
version: 2.1.64
resolution: "@blocksuite/icons@npm:2.1.64"
peerDependencies:
"@types/react": ^18.0.25
lit: ^2.6.1
react: ^18.2.0
peerDependenciesMeta:
lit:
optional: true
react:
optional: true
checksum: 10/4be43918cf50dd5f1c88e8e851b03fc697ad61a01ab67661fdba39b10d3297cc4f2e95e24950f48da990c2c8ee99f0a4e7aad64e171699aaf24be30f139eeafd
languageName: node
linkType: hard

"@blocksuite/icons@npm:^2.1.64":
"@blocksuite/icons@npm:2.1.64, @blocksuite/icons@npm:^2.1.62, @blocksuite/icons@npm:^2.1.64":
version: 2.1.64
resolution: "@blocksuite/icons@npm:2.1.64"
peerDependencies:
Expand Down Expand Up @@ -15339,26 +15323,6 @@ __metadata:
languageName: node
linkType: hard

"@vanilla-extract/css@npm:^1.15.5":
version: 1.15.5
resolution: "@vanilla-extract/css@npm:1.15.5"
dependencies:
"@emotion/hash": "npm:^0.9.0"
"@vanilla-extract/private": "npm:^1.0.6"
css-what: "npm:^6.1.0"
cssesc: "npm:^3.0.0"
csstype: "npm:^3.0.7"
dedent: "npm:^1.5.3"
deep-object-diff: "npm:^1.1.9"
deepmerge: "npm:^4.2.2"
lru-cache: "npm:^10.4.3"
media-query-parser: "npm:^2.0.2"
modern-ahocorasick: "npm:^1.0.0"
picocolors: "npm:^1.0.0"
checksum: 10/4820caea8f7d63d5e691c72d3d324a09707040afa6b0abaaf0fea7d9ee1c133a19e5f3a383fd903453680cd0d698de0428ad2a7316e0c5e9771ffd79d813ddf6
languageName: node
linkType: hard

"@vanilla-extract/dynamic@npm:^2.1.0, @vanilla-extract/dynamic@npm:^2.1.2":
version: 2.1.2
resolution: "@vanilla-extract/dynamic@npm:2.1.2"
Expand Down Expand Up @@ -26185,13 +26149,6 @@ __metadata:
languageName: node
linkType: hard

"lru-cache@npm:^10.4.3":
version: 10.4.3
resolution: "lru-cache@npm:10.4.3"
checksum: 10/e6e90267360476720fa8e83cc168aa2bf0311f3f2eea20a6ba78b90a885ae72071d9db132f40fda4129c803e7dcec3a6b6a6fbb44ca90b081630b810b5d6a41a
languageName: node
linkType: hard

"lru-cache@npm:^11.0.0":
version: 11.0.0
resolution: "lru-cache@npm:11.0.0"
Expand Down

0 comments on commit ce18569

Please sign in to comment.