diff --git a/packages/frontend/core/src/modules/cloud/entities/session.ts b/packages/frontend/core/src/modules/cloud/entities/session.ts index c5dd7b664d..49018306be 100644 --- a/packages/frontend/core/src/modules/cloud/entities/session.ts +++ b/packages/frontend/core/src/modules/cloud/entities/session.ts @@ -7,6 +7,7 @@ import { onComplete, onStart, } from '@toeverything/infra'; +import { isEqual } from 'lodash-es'; import { EMPTY, exhaustMap, mergeMap } from 'rxjs'; import { validateAndReduceImage } from '../../../utils/reduce-image'; @@ -73,7 +74,9 @@ export class AuthSession extends Entity { count: Infinity, }), mergeMap(sessionInfo => { - this.store.setCachedAuthSession(sessionInfo); + if (!isEqual(this.store.getCachedAuthSession(), sessionInfo)) { + this.store.setCachedAuthSession(sessionInfo); + } return EMPTY; }), onStart(() => { diff --git a/packages/frontend/core/src/modules/cloud/stores/auth.ts b/packages/frontend/core/src/modules/cloud/stores/auth.ts index 06e860d70c..abc9c73d0c 100644 --- a/packages/frontend/core/src/modules/cloud/stores/auth.ts +++ b/packages/frontend/core/src/modules/cloud/stores/auth.ts @@ -32,6 +32,10 @@ export class AuthStore extends Store { return this.globalState.watch('affine-cloud-auth'); } + getCachedAuthSession() { + return this.globalState.get('affine-cloud-auth'); + } + setCachedAuthSession(session: AuthSessionInfo | null) { this.globalState.set('affine-cloud-auth', session); }