There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): reduce state refresh (#8181)
EYHN0cdc486f1fbd
diff --git a/packages/frontend/core/src/modules/cloud/entities/session.ts b/packages/frontend/core/src/modules/cloud/entities/session.tsindex 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.tsindex 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<AuthSessionInfo>('affine-cloud-auth');}+ getCachedAuthSession() {+ return this.globalState.get<AuthSessionInfo>('affine-cloud-auth');+ }+setCachedAuthSession(session: AuthSessionInfo | null) {this.globalState.set('affine-cloud-auth', session);}