refactor(core): adjust effect api (#11935)

This commit is contained in:
EYHN
2025-04-24 10:06:11 +00:00
parent 1d38e5787b
commit eaa1bc6bf1
41 changed files with 79 additions and 146 deletions

View File

@@ -10,7 +10,7 @@ import {
Service,
smartRetry,
} from '@toeverything/infra';
import { EMPTY, mergeMap, switchMap, timer } from 'rxjs';
import { switchMap, tap, timer } from 'rxjs';
import { AccountChanged, type AuthService } from '../../cloud';
import { ServerStarted } from '../../cloud/events/server-started';
@@ -45,9 +45,8 @@ export class NotificationCountService extends Service {
}
return this.store.getNotificationCount(signal);
}).pipe(
mergeMap(result => {
tap(result => {
this.setCount(result ?? 0);
return EMPTY;
}),
smartRetry(),
catchErrorInto(this.error$),

View File

@@ -8,7 +8,7 @@ import {
Service,
smartRetry,
} from '@toeverything/infra';
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
import { EMPTY, exhaustMap, tap } from 'rxjs';
import type { Notification, NotificationStore } from '../stores/notification';
import type { NotificationCountService } from './count';
@@ -43,10 +43,10 @@ export class NotificationListService extends Service {
signal
)
).pipe(
mergeMap(result => {
tap(result => {
if (!result) {
// If the user is not logged in, we just ignore the result.
return EMPTY;
return;
}
const { edges, pageInfo, totalCount } = result;
this.notifications$.next([
@@ -59,8 +59,6 @@ export class NotificationListService extends Service {
this.hasMore$.next(pageInfo.hasNextPage);
this.nextCursor$.next(pageInfo.endCursor ?? undefined);
return EMPTY;
}),
smartRetry(),
catchErrorInto(this.error$),