mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
feat(core): reduce profile loading time (#6616)
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import { catchError, EMPTY, from, mergeMap, switchMap } from 'rxjs';
|
||||
import { catchError, EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
|
||||
import { Entity } from '../../../framework';
|
||||
import { effect, LiveData, onComplete, onStart } from '../../../livedata';
|
||||
import {
|
||||
effect,
|
||||
fromPromise,
|
||||
LiveData,
|
||||
onComplete,
|
||||
onStart,
|
||||
} from '../../../livedata';
|
||||
import type { WorkspaceMetadata } from '../metadata';
|
||||
import type { WorkspaceFlavourProvider } from '../providers/flavour';
|
||||
import type { WorkspaceProfileCacheStore } from '../stores/profile-cache';
|
||||
@@ -54,11 +60,12 @@ export class WorkspaceProfile extends Entity<{ metadata: WorkspaceMetadata }> {
|
||||
|
||||
revalidate = effect(
|
||||
switchMap(() => {
|
||||
if (!this.provider) {
|
||||
const provider = this.provider;
|
||||
if (!provider) {
|
||||
return EMPTY;
|
||||
}
|
||||
return from(
|
||||
this.provider.getWorkspaceProfile(this.props.metadata.id)
|
||||
return fromPromise(signal =>
|
||||
provider.getWorkspaceProfile(this.props.metadata.id, signal)
|
||||
).pipe(
|
||||
mergeMap(info => {
|
||||
if (info) {
|
||||
|
||||
@@ -47,7 +47,10 @@ export interface WorkspaceFlavourProvider {
|
||||
*/
|
||||
revalidate?: () => void;
|
||||
|
||||
getWorkspaceProfile(id: string): Promise<WorkspaceProfileInfo | undefined>;
|
||||
getWorkspaceProfile(
|
||||
id: string,
|
||||
signal?: AbortSignal
|
||||
): Promise<WorkspaceProfileInfo | undefined>;
|
||||
|
||||
getWorkspaceBlob(id: string, blob: string): Promise<Blob | null>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user