From 185546b8ea8a3cda05cbcaa424ee787103e239d0 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Fri, 8 Sep 2023 00:14:02 +0800 Subject: [PATCH] fix: logout 404 (#4253) Co-authored-by: Alex Yang --- .../components/pure/workspace-list-modal/index.tsx | 13 ++++++++++--- apps/core/src/utils/cloud-utils.tsx | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/core/src/components/pure/workspace-list-modal/index.tsx b/apps/core/src/components/pure/workspace-list-modal/index.tsx index 8325e5f83f..a733a9cf9b 100644 --- a/apps/core/src/components/pure/workspace-list-modal/index.tsx +++ b/apps/core/src/components/pure/workspace-list-modal/index.tsx @@ -21,7 +21,7 @@ import { Divider } from '@toeverything/components/divider'; import { Menu, MenuIcon, MenuItem } from '@toeverything/components/menu'; import { useSetAtom } from 'jotai'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports -import { signOut, useSession } from 'next-auth/react'; +import { useSession } from 'next-auth/react'; import { useCallback } from 'react'; import { @@ -29,7 +29,9 @@ import { openDisableCloudAlertModalAtom, openSettingModalAtom, } from '../../../atoms'; +import { useNavigateHelper } from '../../../hooks/use-navigate-helper'; import type { AllWorkspace } from '../../../shared'; +import { signOutCloud } from '../../../utils/cloud-utils'; import { StyledCreateWorkspaceCardPill, StyledCreateWorkspaceCardPillContent, @@ -67,6 +69,7 @@ interface WorkspaceModalProps { const AccountMenu = () => { const t = useAFFiNEI18N(); const setOpen = useSetAtom(openSettingModalAtom); + const { jumpToIndex } = useNavigateHelper(); return (
{ } data-testid="editor-option-menu-import" onClick={useCallback(() => { - signOut().catch(console.error); - }, [])} + signOutCloud() + .then(() => { + jumpToIndex(); + }) + .catch(console.error); + }, [jumpToIndex])} > {t['com.affine.workspace.cloud.account.logout']()} diff --git a/apps/core/src/utils/cloud-utils.tsx b/apps/core/src/utils/cloud-utils.tsx index 0676531058..c2b1e43f62 100644 --- a/apps/core/src/utils/cloud-utils.tsx +++ b/apps/core/src/utils/cloud-utils.tsx @@ -91,6 +91,7 @@ export const signOutCloud: typeof signOut = async options => { .then(result => { if (result) { startTransition(() => { + localStorage.removeItem('last_workspace_id'); getCurrentStore().set(refreshRootMetadataAtom); }); }