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
@@ -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 <AppContainer fallback />;
return fallback ?? <AppContainer fallback />;
}
// TODO(@eyhn): We need a no workspace page
return (
<div
style={{
position: 'fixed',
left: 'calc(50% - 150px)',
top: '50%',
}}
>
<WorkspaceNavigator
open={true}
menuContentOptions={{
forceMount: true,
children ?? (
<div
style={{
position: 'fixed',
left: 'calc(50% - 150px)',
top: '50%',
}}
/>
</div>
>
<WorkspaceNavigator
open={true}
menuContentOptions={{
forceMount: true,
}}
/>
</div>
)
);
};