mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
fix(mobile): workspace selector in app-fallback may crash (#9293)
This commit is contained in:
@@ -8,7 +8,11 @@ import {
|
||||
WorkspacesService,
|
||||
} from '@affine/core/modules/workspace';
|
||||
import { CloseIcon, CollaborationIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import {
|
||||
useLiveData,
|
||||
useService,
|
||||
useServiceOptional,
|
||||
} from '@toeverything/infra';
|
||||
import clsx from 'clsx';
|
||||
import { type HTMLAttributes, useCallback, useMemo } from 'react';
|
||||
|
||||
@@ -54,17 +58,17 @@ const WorkspaceList = ({
|
||||
list: WorkspaceMetadata[];
|
||||
onClose?: () => void;
|
||||
}) => {
|
||||
const currentWorkspace = useService(WorkspaceService).workspace;
|
||||
const currentWorkspace = useServiceOptional(WorkspaceService)?.workspace;
|
||||
|
||||
const { jumpToPage } = useNavigateHelper();
|
||||
const toggleWorkspace = useCallback(
|
||||
(id: string) => {
|
||||
if (id !== currentWorkspace.id) {
|
||||
if (id !== currentWorkspace?.id) {
|
||||
jumpToPage(id, 'home');
|
||||
}
|
||||
onClose?.();
|
||||
},
|
||||
[currentWorkspace.id, jumpToPage, onClose]
|
||||
[currentWorkspace?.id, jumpToPage, onClose]
|
||||
);
|
||||
|
||||
if (!list.length) return null;
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { RouteObject } from 'react-router-dom';
|
||||
import {
|
||||
createBrowserRouter as reactRouterCreateBrowserRouter,
|
||||
redirect,
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
// oxlint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
useNavigate,
|
||||
} from 'react-router-dom';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user