Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(core): independent app fallback for mobile (#8884)

EYHNa4c749b8822a
diff --git a/packages/frontend/apps/android/src/app.tsx b/packages/frontend/apps/android/src/app.tsx
index 70142b3611..5a19af732a 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 { AppContainer } from '@affine/core/desktop/components/app-container';
+import { AppFallback } from '@affine/core/mobile/components/app-fallback';
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() {
<I18nProvider>
<AffineContext store={getCurrentStore()}>
<RouterProvider
- fallbackElement={<AppContainer fallback />}
+ fallbackElement={<AppFallback />}
router={router}
future={future}
/>
diff --git a/packages/frontend/apps/ios/src/app.tsx b/packages/frontend/apps/ios/src/app.tsx
index 327871da60..6cab81b479 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 { AppContainer } from '@affine/core/desktop/components/app-container';
+import { AppFallback } from '@affine/core/mobile/components/app-fallback';
import { configureMobileModules } from '@affine/core/mobile/modules';
import { VirtualKeyboardProvider } from '@affine/core/mobile/modules/virtual-keyboard';
import { router } from '@affine/core/mobile/router';
@@ -133,7 +133,7 @@ export function App() {
<I18nProvider>
<AffineContext store={getCurrentStore()}>
<RouterProvider
- fallbackElement={<AppContainer fallback />}
+ fallbackElement={<AppFallback />}
router={router}
future={future}
/>
diff --git a/packages/frontend/apps/mobile/src/app.tsx b/packages/frontend/apps/mobile/src/app.tsx
index fe76c737bf..6396cf2054 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 { AppContainer } from '@affine/core/desktop/components/app-container';
+import { AppFallback } from '@affine/core/mobile/components/app-fallback';
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() {
<I18nProvider>
<AffineContext store={getCurrentStore()}>
<RouterProvider
- fallbackElement={<AppContainer fallback />}
+ fallbackElement={<AppFallback />}
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 e4a3143708..249958723c 100644
--- a/packages/frontend/core/src/desktop/components/app-container/index.tsx
+++ b/packages/frontend/core/src/desktop/components/app-container/index.tsx
@@ -22,7 +22,6 @@ import {
type ReactElement,
} from 'react';
-import { AppFallback } from './mobile';
import * as styles from './styles.css';
export const AppContainer = ({
@@ -103,23 +102,7 @@ const BrowserLayout = ({
);
};
-const MobileLayout = ({
- children,
- fallback = false,
-}: PropsWithChildren<{ fallback?: boolean }>) => {
- return (
- <div className={styles.browserAppViewContainer}>
- {fallback ? <AppFallback /> : null}
- <MainContainer>{children}</MainContainer>
- </div>
- );
-};
-
-const LayoutComponent = BUILD_CONFIG.isElectron
- ? DesktopLayout
- : BUILD_CONFIG.isMobileEdition
- ? MobileLayout
- : BrowserLayout;
+const LayoutComponent = BUILD_CONFIG.isElectron ? DesktopLayout : BrowserLayout;
const MainContainer = forwardRef<
HTMLDivElement,
diff --git a/packages/frontend/core/src/desktop/components/app-container/mobile.tsx b/packages/frontend/core/src/mobile/components/app-fallback/index.tsx
similarity index 96%
rename from packages/frontend/core/src/desktop/components/app-container/mobile.tsx
rename to packages/frontend/core/src/mobile/components/app-fallback/index.tsx
index 8cf2dd3807..273115aac3 100644
--- a/packages/frontend/core/src/desktop/components/app-container/mobile.tsx
+++ b/packages/frontend/core/src/mobile/components/app-fallback/index.tsx
@@ -1,5 +1,6 @@
import { SafeArea, Skeleton } from '@affine/component';
-import { WorkspaceSelector } from '@affine/core/mobile/components';
+
+import { WorkspaceSelector } from '../workspace-selector';
const SectionTitleFallback = () => {
return (
diff --git a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx
index 918b31b73a..850dccfac1 100644
--- a/packages/frontend/core/src/mobile/pages/workspace/layout.tsx
+++ b/packages/frontend/core/src/mobile/pages/workspace/layout.tsx
@@ -6,7 +6,6 @@ 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';
@@ -24,6 +23,7 @@ import {
useState,
} from 'react';
+import { AppFallback } from '../../components/app-fallback';
import { WorkspaceDialogs } from '../../dialogs';
// TODO(@forehalo): reuse the global context with [core/electron]
@@ -91,7 +91,7 @@ export const WorkspaceLayout = ({
}
if (!isRootDocReady) {
- return <AppContainer fallback />;
+ return <AppFallback />;
}
return (