feat(mobile): use mobile fallback for index, open home when workspace changed (#9106)

This commit is contained in:
CatsJuice
2024-12-13 07:41:06 +00:00
parent 974c6de1d2
commit 6f6f95a8b0
5 changed files with 29 additions and 18 deletions

View File

@@ -163,8 +163,8 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */;
buildPhases = ( buildPhases = (
C4C97C6A2D0300E100BC2AD1 /* Build Rust */,
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */, 6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */,
C4C97C6A2D0300E100BC2AD1 /* Build Rust */,
504EC3001FED79650016851F /* Sources */, 504EC3001FED79650016851F /* Sources */,
504EC3011FED79650016851F /* Frameworks */, 504EC3011FED79650016851F /* Frameworks */,
504EC3021FED79650016851F /* Resources */, 504EC3021FED79650016851F /* Resources */,

View File

@@ -50,4 +50,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: e0c0ccf027ea6d51e476f0baf9d44d97b9a90a4b PODFILE CHECKSUM: e0c0ccf027ea6d51e476f0baf9d44d97b9a90a4b
COCOAPODS: 1.15.2 COCOAPODS: 1.16.2

View File

@@ -10,6 +10,7 @@ import {
WorkspacesService, WorkspacesService,
} from '@toeverything/infra'; } from '@toeverything/infra';
import { import {
type ReactNode,
useCallback, useCallback,
useEffect, useEffect,
useLayoutEffect, useLayoutEffect,
@@ -34,8 +35,12 @@ import { AppContainer } from '../../components/app-container';
*/ */
export const Component = ({ export const Component = ({
defaultIndexRoute = 'all', defaultIndexRoute = 'all',
children,
fallback,
}: { }: {
defaultIndexRoute?: string; defaultIndexRoute?: string;
children?: ReactNode;
fallback?: ReactNode;
}) => { }) => {
// navigating and creating may be slow, to avoid flickering, we show workspace fallback // navigating and creating may be slow, to avoid flickering, we show workspace fallback
const [navigating, setNavigating] = useState(true); const [navigating, setNavigating] = useState(true);
@@ -146,24 +151,26 @@ export const Component = ({
}, [jumpToPage, openPage, workspacesService]); }, [jumpToPage, openPage, workspacesService]);
if (navigating || creating) { if (navigating || creating) {
return <AppContainer fallback />; return fallback ?? <AppContainer fallback />;
} }
// TODO(@eyhn): We need a no workspace page // TODO(@eyhn): We need a no workspace page
return ( return (
<div children ?? (
style={{ <div
position: 'fixed', style={{
left: 'calc(50% - 150px)', position: 'fixed',
top: '50%', left: 'calc(50% - 150px)',
}} top: '50%',
>
<WorkspaceNavigator
open={true}
menuContentOptions={{
forceMount: true,
}} }}
/> >
</div> <WorkspaceNavigator
open={true}
menuContentOptions={{
forceMount: true,
}}
/>
</div>
)
); );
}; };

View File

@@ -61,7 +61,7 @@ const WorkspaceList = ({
const toggleWorkspace = useCallback( const toggleWorkspace = useCallback(
(id: string) => { (id: string) => {
if (id !== currentWorkspace.id) { if (id !== currentWorkspace.id) {
jumpToPage(id, 'all'); jumpToPage(id, 'home');
} }
onClose?.(); onClose?.();
}, },

View File

@@ -1,8 +1,12 @@
import { Component as IndexComponent } from '@affine/core/desktop/pages/index'; import { Component as IndexComponent } from '@affine/core/desktop/pages/index';
import { AppFallback } from '../components/app-fallback';
// Default route fallback for mobile // Default route fallback for mobile
export const Component = () => { export const Component = () => {
// TODO: replace with a mobile version // TODO: replace with a mobile version
return <IndexComponent defaultIndexRoute={'home'} />; return (
<IndexComponent defaultIndexRoute={'home'} fallback={<AppFallback />} />
);
}; };