mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
fix(core): reduce state refresh (#8181)
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
onComplete,
|
onComplete,
|
||||||
onStart,
|
onStart,
|
||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
|
import { isEqual } from 'lodash-es';
|
||||||
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||||
|
|
||||||
import { validateAndReduceImage } from '../../../utils/reduce-image';
|
import { validateAndReduceImage } from '../../../utils/reduce-image';
|
||||||
@@ -73,7 +74,9 @@ export class AuthSession extends Entity {
|
|||||||
count: Infinity,
|
count: Infinity,
|
||||||
}),
|
}),
|
||||||
mergeMap(sessionInfo => {
|
mergeMap(sessionInfo => {
|
||||||
this.store.setCachedAuthSession(sessionInfo);
|
if (!isEqual(this.store.getCachedAuthSession(), sessionInfo)) {
|
||||||
|
this.store.setCachedAuthSession(sessionInfo);
|
||||||
|
}
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}),
|
}),
|
||||||
onStart(() => {
|
onStart(() => {
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ export class AuthStore extends Store {
|
|||||||
return this.globalState.watch<AuthSessionInfo>('affine-cloud-auth');
|
return this.globalState.watch<AuthSessionInfo>('affine-cloud-auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCachedAuthSession() {
|
||||||
|
return this.globalState.get<AuthSessionInfo>('affine-cloud-auth');
|
||||||
|
}
|
||||||
|
|
||||||
setCachedAuthSession(session: AuthSessionInfo | null) {
|
setCachedAuthSession(session: AuthSessionInfo | null) {
|
||||||
this.globalState.set('affine-cloud-auth', session);
|
this.globalState.set('affine-cloud-auth', session);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user