mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
fix: logout 404 (#4253)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import { Divider } from '@toeverything/components/divider';
|
|||||||
import { Menu, MenuIcon, MenuItem } from '@toeverything/components/menu';
|
import { Menu, MenuIcon, MenuItem } from '@toeverything/components/menu';
|
||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
// 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 { useCallback } from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -29,7 +29,9 @@ import {
|
|||||||
openDisableCloudAlertModalAtom,
|
openDisableCloudAlertModalAtom,
|
||||||
openSettingModalAtom,
|
openSettingModalAtom,
|
||||||
} from '../../../atoms';
|
} from '../../../atoms';
|
||||||
|
import { useNavigateHelper } from '../../../hooks/use-navigate-helper';
|
||||||
import type { AllWorkspace } from '../../../shared';
|
import type { AllWorkspace } from '../../../shared';
|
||||||
|
import { signOutCloud } from '../../../utils/cloud-utils';
|
||||||
import {
|
import {
|
||||||
StyledCreateWorkspaceCardPill,
|
StyledCreateWorkspaceCardPill,
|
||||||
StyledCreateWorkspaceCardPillContent,
|
StyledCreateWorkspaceCardPillContent,
|
||||||
@@ -67,6 +69,7 @@ interface WorkspaceModalProps {
|
|||||||
const AccountMenu = () => {
|
const AccountMenu = () => {
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
const setOpen = useSetAtom(openSettingModalAtom);
|
const setOpen = useSetAtom(openSettingModalAtom);
|
||||||
|
const { jumpToIndex } = useNavigateHelper();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@@ -91,8 +94,12 @@ const AccountMenu = () => {
|
|||||||
}
|
}
|
||||||
data-testid="editor-option-menu-import"
|
data-testid="editor-option-menu-import"
|
||||||
onClick={useCallback(() => {
|
onClick={useCallback(() => {
|
||||||
signOut().catch(console.error);
|
signOutCloud()
|
||||||
}, [])}
|
.then(() => {
|
||||||
|
jumpToIndex();
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
|
}, [jumpToIndex])}
|
||||||
>
|
>
|
||||||
{t['com.affine.workspace.cloud.account.logout']()}
|
{t['com.affine.workspace.cloud.account.logout']()}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export const signOutCloud: typeof signOut = async options => {
|
|||||||
.then(result => {
|
.then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
|
localStorage.removeItem('last_workspace_id');
|
||||||
getCurrentStore().set(refreshRootMetadataAtom);
|
getCurrentStore().set(refreshRootMetadataAtom);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user