fix: logout 404 (#4253)

Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
Peng Xiao 2023-09-08 00:14:02 +08:00 committed by GitHub
parent fcf041024f
commit 185546b8ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -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>

View File

@ -91,6 +91,7 @@ export const signOutCloud: typeof signOut = async options => {
.then(result => {
if (result) {
startTransition(() => {
localStorage.removeItem('last_workspace_id');
getCurrentStore().set(refreshRootMetadataAtom);
});
}