mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
fix(core): reduce state refresh (#8181)
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user