mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
fix(core): refresh metadata after refresh (#4054)
This commit is contained in:
24
apps/core/src/utils/cloud-utils.tsx
Normal file
24
apps/core/src/utils/cloud-utils.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { refreshRootMetadataAtom } from '@affine/workspace/atom';
|
||||
import { getCurrentStore } from '@toeverything/infra/atom';
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
import { signIn, signOut } from 'next-auth/react';
|
||||
import { startTransition } from 'react';
|
||||
|
||||
export const signInCloud: typeof signIn = async (...args) => {
|
||||
return signIn(...args).then(result => {
|
||||
// do not refresh root metadata,
|
||||
// because the session won't change in this callback
|
||||
return result;
|
||||
});
|
||||
};
|
||||
|
||||
export const signOutCloud: typeof signOut = async (...args) => {
|
||||
return signOut(...args).then(result => {
|
||||
if (result) {
|
||||
startTransition(() => {
|
||||
getCurrentStore().set(refreshRootMetadataAtom);
|
||||
});
|
||||
}
|
||||
return result;
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user