From ffa4d5422db85c30841b06f4c570ef18cd3829e6 Mon Sep 17 00:00:00 2001 From: CatsJuice Date: Mon, 18 Nov 2024 02:31:16 +0000 Subject: [PATCH] fix(mobile): use mobile app-fallback in app-container (#8804) close AF-1633 --- packages/frontend/apps/android/src/app.tsx | 4 ++-- packages/frontend/apps/ios/App/Podfile.lock | 2 +- packages/frontend/apps/ios/src/app.tsx | 4 ++-- packages/frontend/apps/mobile/src/app.tsx | 4 ++-- .../components/app-container/index.tsx | 19 ++++++++++++++++++- .../components/app-container/mobile.tsx} | 3 +-- .../core/src/mobile/components/index.ts | 1 - .../src/mobile/components/skeletons/index.tsx | 1 - .../src/mobile/pages/workspace/layout.tsx | 4 ++-- 9 files changed, 28 insertions(+), 14 deletions(-) rename packages/frontend/core/src/{mobile/components/skeletons/app-fallback.tsx => desktop/components/app-container/mobile.tsx} (96%) delete mode 100644 packages/frontend/core/src/mobile/components/skeletons/index.tsx diff --git a/packages/frontend/apps/android/src/app.tsx b/packages/frontend/apps/android/src/app.tsx index ac43d5e79c..70142b3611 100644 --- a/packages/frontend/apps/android/src/app.tsx +++ b/packages/frontend/apps/android/src/app.tsx @@ -1,5 +1,5 @@ import { AffineContext } from '@affine/core/components/context'; -import { AppFallback } from '@affine/core/mobile/components'; +import { AppContainer } from '@affine/core/desktop/components/app-container'; import { configureMobileModules } from '@affine/core/mobile/modules'; import { router } from '@affine/core/mobile/router'; import { configureCommonModules } from '@affine/core/modules'; @@ -47,7 +47,7 @@ export function App() { } + fallbackElement={} router={router} future={future} /> diff --git a/packages/frontend/apps/ios/App/Podfile.lock b/packages/frontend/apps/ios/App/Podfile.lock index 5a7ee08b80..21f407e744 100644 --- a/packages/frontend/apps/ios/App/Podfile.lock +++ b/packages/frontend/apps/ios/App/Podfile.lock @@ -44,4 +44,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 1b0d3fe81862c0e9ce712ddd0c5a0accd0097698 -COCOAPODS: 1.16.1 +COCOAPODS: 1.16.2 diff --git a/packages/frontend/apps/ios/src/app.tsx b/packages/frontend/apps/ios/src/app.tsx index 55ed00565c..c981009611 100644 --- a/packages/frontend/apps/ios/src/app.tsx +++ b/packages/frontend/apps/ios/src/app.tsx @@ -1,5 +1,5 @@ import { AffineContext } from '@affine/core/components/context'; -import { AppFallback } from '@affine/core/mobile/components'; +import { AppContainer } from '@affine/core/desktop/components/app-container'; import { configureMobileModules } from '@affine/core/mobile/modules'; import { router } from '@affine/core/mobile/router'; import { configureCommonModules } from '@affine/core/modules'; @@ -123,7 +123,7 @@ export function App() { } + fallbackElement={} router={router} future={future} /> diff --git a/packages/frontend/apps/mobile/src/app.tsx b/packages/frontend/apps/mobile/src/app.tsx index fb3010d245..fe76c737bf 100644 --- a/packages/frontend/apps/mobile/src/app.tsx +++ b/packages/frontend/apps/mobile/src/app.tsx @@ -1,5 +1,5 @@ import { AffineContext } from '@affine/core/components/context'; -import { AppFallback } from '@affine/core/mobile/components'; +import { AppContainer } from '@affine/core/desktop/components/app-container'; import { configureMobileModules } from '@affine/core/mobile/modules'; import { router } from '@affine/core/mobile/router'; import { configureCommonModules } from '@affine/core/modules'; @@ -67,7 +67,7 @@ export function App() { } + fallbackElement={} router={router} future={future} /> diff --git a/packages/frontend/core/src/desktop/components/app-container/index.tsx b/packages/frontend/core/src/desktop/components/app-container/index.tsx index 249958723c..e4a3143708 100644 --- a/packages/frontend/core/src/desktop/components/app-container/index.tsx +++ b/packages/frontend/core/src/desktop/components/app-container/index.tsx @@ -22,6 +22,7 @@ import { type ReactElement, } from 'react'; +import { AppFallback } from './mobile'; import * as styles from './styles.css'; export const AppContainer = ({ @@ -102,7 +103,23 @@ const BrowserLayout = ({ ); }; -const LayoutComponent = BUILD_CONFIG.isElectron ? DesktopLayout : BrowserLayout; +const MobileLayout = ({ + children, + fallback = false, +}: PropsWithChildren<{ fallback?: boolean }>) => { + return ( +
+ {fallback ? : null} + {children} +
+ ); +}; + +const LayoutComponent = BUILD_CONFIG.isElectron + ? DesktopLayout + : BUILD_CONFIG.isMobileEdition + ? MobileLayout + : BrowserLayout; const MainContainer = forwardRef< HTMLDivElement, diff --git a/packages/frontend/core/src/mobile/components/skeletons/app-fallback.tsx b/packages/frontend/core/src/desktop/components/app-container/mobile.tsx similarity index 96% rename from packages/frontend/core/src/mobile/components/skeletons/app-fallback.tsx rename to packages/frontend/core/src/desktop/components/app-container/mobile.tsx index 273115aac3..8cf2dd3807 100644 --- a/packages/frontend/core/src/mobile/components/skeletons/app-fallback.tsx +++ b/packages/frontend/core/src/desktop/components/app-container/mobile.tsx @@ -1,6 +1,5 @@ import { SafeArea, Skeleton } from '@affine/component'; - -import { WorkspaceSelector } from '../workspace-selector'; +import { WorkspaceSelector } from '@affine/core/mobile/components'; const SectionTitleFallback = () => { return ( diff --git a/packages/frontend/core/src/mobile/components/index.ts b/packages/frontend/core/src/mobile/components/index.ts index 696e783591..2cbbc0f580 100644 --- a/packages/frontend/core/src/mobile/components/index.ts +++ b/packages/frontend/core/src/mobile/components/index.ts @@ -3,6 +3,5 @@ export * from './doc-card'; export * from './rename'; export * from './search-input'; export * from './search-result'; -export * from './skeletons'; export * from './user-plan-tag'; export * from './workspace-selector'; diff --git a/packages/frontend/core/src/mobile/components/skeletons/index.tsx b/packages/frontend/core/src/mobile/components/skeletons/index.tsx deleted file mode 100644 index cc9deefffd..0000000000 --- a/packages/frontend/core/src/mobile/components/skeletons/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from './app-fallback'; diff --git a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx index 7e5b038b7d..918b31b73a 100644 --- a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx +++ b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx @@ -6,6 +6,7 @@ import { } from '@affine/core/components/affine/quota-reached-modal'; import { SWRConfigProvider } from '@affine/core/components/providers/swr-config-provider'; import { WorkspaceSideEffects } from '@affine/core/components/providers/workspace-side-effects'; +import { AppContainer } from '@affine/core/desktop/components/app-container'; import { PeekViewManagerModal } from '@affine/core/modules/peek-view'; import { WorkspaceFlavour } from '@affine/env/workspace'; import type { Workspace, WorkspaceMetadata } from '@toeverything/infra'; @@ -23,7 +24,6 @@ import { useState, } from 'react'; -import { AppFallback } from '../../components'; import { WorkspaceDialogs } from '../../dialogs'; // TODO(@forehalo): reuse the global context with [core/electron] @@ -91,7 +91,7 @@ export const WorkspaceLayout = ({ } if (!isRootDocReady) { - return ; + return ; } return (