From 6f6f95a8b0fdde1bd015d042e9a69fd38b5ce166 Mon Sep 17 00:00:00 2001 From: CatsJuice Date: Fri, 13 Dec 2024 07:41:06 +0000 Subject: [PATCH] feat(mobile): use mobile fallback for index, open home when workspace changed (#9106) --- .../ios/App/App.xcodeproj/project.pbxproj | 2 +- packages/frontend/apps/ios/App/Podfile.lock | 2 +- .../core/src/desktop/pages/index/index.tsx | 35 +++++++++++-------- .../components/workspace-selector/menu.tsx | 2 +- .../frontend/core/src/mobile/pages/index.tsx | 6 +++- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj b/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj index db3b1cfc90..7964dc8f36 100644 --- a/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj +++ b/packages/frontend/apps/ios/App/App.xcodeproj/project.pbxproj @@ -163,8 +163,8 @@ isa = PBXNativeTarget; buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; buildPhases = ( - C4C97C6A2D0300E100BC2AD1 /* Build Rust */, 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */, + C4C97C6A2D0300E100BC2AD1 /* Build Rust */, 504EC3001FED79650016851F /* Sources */, 504EC3011FED79650016851F /* Frameworks */, 504EC3021FED79650016851F /* Resources */, diff --git a/packages/frontend/apps/ios/App/Podfile.lock b/packages/frontend/apps/ios/App/Podfile.lock index 759c19c7f5..934d930c0e 100644 --- a/packages/frontend/apps/ios/App/Podfile.lock +++ b/packages/frontend/apps/ios/App/Podfile.lock @@ -50,4 +50,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: e0c0ccf027ea6d51e476f0baf9d44d97b9a90a4b -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/packages/frontend/core/src/desktop/pages/index/index.tsx b/packages/frontend/core/src/desktop/pages/index/index.tsx index 38fa4b66ed..819323a40f 100644 --- a/packages/frontend/core/src/desktop/pages/index/index.tsx +++ b/packages/frontend/core/src/desktop/pages/index/index.tsx @@ -10,6 +10,7 @@ import { WorkspacesService, } from '@toeverything/infra'; import { + type ReactNode, useCallback, useEffect, useLayoutEffect, @@ -34,8 +35,12 @@ import { AppContainer } from '../../components/app-container'; */ export const Component = ({ defaultIndexRoute = 'all', + children, + fallback, }: { defaultIndexRoute?: string; + children?: ReactNode; + fallback?: ReactNode; }) => { // navigating and creating may be slow, to avoid flickering, we show workspace fallback const [navigating, setNavigating] = useState(true); @@ -146,24 +151,26 @@ export const Component = ({ }, [jumpToPage, openPage, workspacesService]); if (navigating || creating) { - return ; + return fallback ?? ; } // TODO(@eyhn): We need a no workspace page return ( -
- -
+ > + + + ) ); }; diff --git a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx index 42d757348d..5d21ac7cae 100644 --- a/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx +++ b/packages/frontend/core/src/mobile/components/workspace-selector/menu.tsx @@ -61,7 +61,7 @@ const WorkspaceList = ({ const toggleWorkspace = useCallback( (id: string) => { if (id !== currentWorkspace.id) { - jumpToPage(id, 'all'); + jumpToPage(id, 'home'); } onClose?.(); }, diff --git a/packages/frontend/core/src/mobile/pages/index.tsx b/packages/frontend/core/src/mobile/pages/index.tsx index aed12fe284..8b02724119 100644 --- a/packages/frontend/core/src/mobile/pages/index.tsx +++ b/packages/frontend/core/src/mobile/pages/index.tsx @@ -1,8 +1,12 @@ import { Component as IndexComponent } from '@affine/core/desktop/pages/index'; +import { AppFallback } from '../components/app-fallback'; + // Default route fallback for mobile export const Component = () => { // TODO: replace with a mobile version - return ; + return ( + } /> + ); };