refactor(core): adjust effect api (#11935)
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap, switchMap } from 'rxjs';
|
||||
import { map, switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspaceMembersStore } from '../stores/members';
|
||||
@@ -45,10 +45,9 @@ export class WorkspaceMembers extends Entity {
|
||||
signal
|
||||
);
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.memberCount$.setValue(data.memberCount);
|
||||
this.pageMembers$.setValue(data.members);
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
onComplete,
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspacePermissionStore } from '../stores/permission';
|
||||
@@ -51,13 +51,12 @@ export class WorkspacePermission extends Entity {
|
||||
backoffRetry({
|
||||
count: Infinity,
|
||||
}),
|
||||
mergeMap(({ isOwner, isAdmin, isTeam }) => {
|
||||
tap(({ isOwner, isAdmin, isTeam }) => {
|
||||
this.store.setWorkspacePermissionCache({
|
||||
isOwner,
|
||||
isAdmin,
|
||||
isTeam,
|
||||
});
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => this.isRevalidating$.setValue(true)),
|
||||
onComplete(() => this.isRevalidating$.setValue(false))
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { EMPTY, exhaustMap, tap } from 'rxjs';
|
||||
|
||||
import type { DocService } from '../../doc';
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
@@ -52,7 +52,7 @@ export class DocGrantedUsersService extends Service {
|
||||
signal
|
||||
);
|
||||
}).pipe(
|
||||
mergeMap(({ edges, pageInfo, totalCount }) => {
|
||||
tap(({ edges, pageInfo, totalCount }) => {
|
||||
this.grantedUsers$.next([
|
||||
...this.grantedUsers$.value,
|
||||
...edges.map(edge => edge.node),
|
||||
@@ -61,8 +61,6 @@ export class DocGrantedUsersService extends Service {
|
||||
this.grantedUserCount$.next(totalCount);
|
||||
this.hasMore$.next(pageInfo.hasNextPage);
|
||||
this.nextCursor$.next(pageInfo.endCursor ?? undefined);
|
||||
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import {
|
||||
combineLatest,
|
||||
EMPTY,
|
||||
exhaustMap,
|
||||
groupBy,
|
||||
map,
|
||||
@@ -145,8 +144,7 @@ export class GuardService extends Service {
|
||||
fromPromise(() => this.guardStore.getWorkspacePermissions()).pipe(
|
||||
backoffRetry({
|
||||
count: Infinity,
|
||||
}),
|
||||
mergeMap(() => EMPTY)
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -159,8 +157,7 @@ export class GuardService extends Service {
|
||||
fromPromise(() => this.loadDocPermission(docId)).pipe(
|
||||
backoffRetry({
|
||||
count: Infinity,
|
||||
}),
|
||||
mergeMap(() => EMPTY)
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { EMPTY, exhaustMap, tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { Member } from '../entities/members';
|
||||
@@ -43,11 +43,9 @@ export class MemberSearchService extends Service {
|
||||
signal
|
||||
);
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.result$.setValue([...this.result$.value, ...data.members]);
|
||||
this.hasMore$.setValue(data.members.length === this.PAGE_SIZE);
|
||||
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
Reference in New Issue
Block a user