Skip to content

Commit

Permalink
fix(mobile): workspace selector in app-fallback may crash (#9293)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatsJuice committed Dec 25, 2024
1 parent 727f21d commit a29519a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/core/src/mobile/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit a29519a

Please sign in to comment.