Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: logout 404 (#4253)

Peng Xiao185546b8ea8a
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 (
<div>
<MenuItem
@@ -91,8 +94,12 @@ const AccountMenu = () => {
}
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']()}
</MenuItem>
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);
});
}