fix(core): refresh metadata after refresh (#4054)

This commit is contained in:
Alex Yang
2023-08-30 16:22:34 -05:00
committed by GitHub
parent 441e706746
commit 517f4afb31
10 changed files with 204 additions and 132 deletions

View 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;
});
};