mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
refactor(core): adjust effect api (#11935)
This commit is contained in:
@@ -44,14 +44,7 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { useEffect } from 'react';
|
||||
import {
|
||||
catchError,
|
||||
EMPTY,
|
||||
finalize,
|
||||
mergeMap,
|
||||
switchMap,
|
||||
timeout,
|
||||
} from 'rxjs';
|
||||
import { catchError, EMPTY, finalize, switchMap, tap, timeout } from 'rxjs';
|
||||
|
||||
/**
|
||||
* @deprecated just for legacy code, will be removed in the future
|
||||
@@ -88,12 +81,11 @@ export const WorkspaceSideEffects = () => {
|
||||
return { doc, mode };
|
||||
}).pipe(
|
||||
timeout(10000 /* 10s */),
|
||||
mergeMap(({ mode, doc }) => {
|
||||
tap(({ mode, doc }) => {
|
||||
if (doc) {
|
||||
docsList.setPrimaryMode(doc.id, mode as DocMode);
|
||||
workbench.openDoc(doc.id);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => {
|
||||
pushGlobalLoadingEvent({
|
||||
|
||||
@@ -11,7 +11,7 @@ import { effect, fromPromise, useServices } from '@toeverything/infra';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
import { switchMap } from 'rxjs';
|
||||
|
||||
import { generateSubscriptionCallbackLink } from '../../../components/hooks/affine/use-subscription-notify';
|
||||
import {
|
||||
@@ -162,7 +162,7 @@ export const Component = () => {
|
||||
const e = UserFriendlyError.fromAny(err);
|
||||
setMessage(e.message);
|
||||
}
|
||||
}).pipe(mergeMap(() => EMPTY));
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
LiveData,
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
import { catchError, distinctUntilChanged, EMPTY, mergeMap } from 'rxjs';
|
||||
import { catchError, distinctUntilChanged, EMPTY } from 'rxjs';
|
||||
|
||||
import type { NavigationGestureProvider } from '../providers/navigation-gesture';
|
||||
|
||||
@@ -35,7 +35,6 @@ export class NavigationGestureService extends Service {
|
||||
}
|
||||
return;
|
||||
}).pipe(
|
||||
mergeMap(() => EMPTY),
|
||||
catchError(err => {
|
||||
logger.error('navigationGestureProvider error', err);
|
||||
return EMPTY;
|
||||
|
||||
@@ -5,13 +5,7 @@ import {
|
||||
fromPromise,
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
import {
|
||||
catchError,
|
||||
distinctUntilChanged,
|
||||
EMPTY,
|
||||
mergeMap,
|
||||
throttleTime,
|
||||
} from 'rxjs';
|
||||
import { catchError, distinctUntilChanged, EMPTY, throttleTime } from 'rxjs';
|
||||
|
||||
import type { AIButtonProvider } from '../provider/ai-button';
|
||||
|
||||
@@ -37,7 +31,6 @@ export class AIButtonService extends Service {
|
||||
}
|
||||
return;
|
||||
}).pipe(
|
||||
mergeMap(() => EMPTY),
|
||||
catchError(err => {
|
||||
logger.error('presentAIButton error', err);
|
||||
return EMPTY;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
onStart,
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
import { switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { DesktopApiService } from '../../desktop-api';
|
||||
import type { WorkspacesService } from '../../workspace';
|
||||
@@ -37,9 +37,8 @@ export class BackupService extends Service {
|
||||
fromPromise(async () => {
|
||||
return this.desktopApiService.handler.workspace.getBackupWorkspaces();
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.pageBackupWorkspaces$.setValue(data);
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isLoading$.setValue(true)),
|
||||
|
||||
@@ -9,14 +9,13 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import { fileTypeFromBuffer } from 'file-type';
|
||||
import {
|
||||
EMPTY,
|
||||
filter,
|
||||
firstValueFrom,
|
||||
fromEvent,
|
||||
map,
|
||||
mergeMap,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
tap,
|
||||
} from 'rxjs';
|
||||
|
||||
import type { DocsSearchService } from '../../docs-search';
|
||||
@@ -46,9 +45,8 @@ export class UnusedBlobs extends Entity {
|
||||
fromPromise(async () => {
|
||||
return await this.getUnusedBlobs();
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.unusedBlobs$.setValue(data);
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => this.isLoading$.setValue(true)),
|
||||
onComplete(() => this.isLoading$.setValue(false))
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { DocService } from '../../doc';
|
||||
import type { GlobalCache } from '../../storage';
|
||||
@@ -47,9 +47,8 @@ export class CloudDocMeta extends Entity {
|
||||
this.store.fetchCloudDocMeta(this.workspaceId, this.docId)
|
||||
).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(meta => {
|
||||
tap(meta => {
|
||||
this.cache.set<CloudDocMetaType>(this.cacheKey, meta);
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { InvoicesStore } from '../stores/invoices';
|
||||
|
||||
@@ -44,10 +44,9 @@ export class Invoices extends Entity {
|
||||
signal
|
||||
);
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.invoiceCount$.setValue(data.invoiceCount);
|
||||
this.pageInvoices$.setValue(data.invoices);
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
onComplete,
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, map, mergeMap } from 'rxjs';
|
||||
import { exhaustMap, map, tap } from 'rxjs';
|
||||
|
||||
import { ServerScope } from '../scopes/server';
|
||||
import { AuthService } from '../services/auth';
|
||||
@@ -77,7 +77,7 @@ export class Server extends Entity<{
|
||||
backoffRetry({
|
||||
count: Infinity,
|
||||
}),
|
||||
mergeMap(config => {
|
||||
tap(config => {
|
||||
this.serverListStore.updateServerConfig(this.serverMetadata.id, {
|
||||
credentialsRequirement: config.credentialsRequirement,
|
||||
features: config.features,
|
||||
@@ -87,7 +87,6 @@ export class Server extends Entity<{
|
||||
version: config.version,
|
||||
initialized: config.initialized,
|
||||
});
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => {
|
||||
this.isConfigRevalidating$.next(true);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import { validateAndReduceImage } from '../../../utils/reduce-image';
|
||||
import type { AccountProfile, AuthStore } from '../stores/auth';
|
||||
@@ -78,11 +78,10 @@ export class AuthSession extends Entity {
|
||||
backoffRetry({
|
||||
count: Infinity,
|
||||
}),
|
||||
mergeMap(sessionInfo => {
|
||||
tap(sessionInfo => {
|
||||
if (!isEqual(this.store.getCachedAuthSession(), sessionInfo)) {
|
||||
this.store.setCachedAuthSession(sessionInfo);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => {
|
||||
this.isRevalidating$.next(true);
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { AuthService } from '../services/auth';
|
||||
import type { ServerService } from '../services/server';
|
||||
@@ -122,7 +122,7 @@ export class Subscription extends Entity {
|
||||
};
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
this.store.setCachedSubscriptions(
|
||||
data.userId,
|
||||
@@ -132,7 +132,6 @@ export class Subscription extends Entity {
|
||||
} else {
|
||||
this.subscription$.next(undefined);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { AuthService } from '../services/auth';
|
||||
import type { ServerService } from '../services/server';
|
||||
@@ -54,7 +54,7 @@ export class UserCopilotQuota extends Entity {
|
||||
return aiQuota;
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
const { limit, used } = data;
|
||||
this.copilotActionUsed$.next(used);
|
||||
@@ -65,7 +65,6 @@ export class UserCopilotQuota extends Entity {
|
||||
this.copilotActionUsed$.next(null);
|
||||
this.copilotActionLimit$.next(null);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { AuthService } from '../services/auth';
|
||||
import type { UserFeatureStore } from '../stores/user-feature';
|
||||
@@ -64,13 +64,12 @@ export class UserFeature extends Entity {
|
||||
};
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
this.features$.next(data.features);
|
||||
} else {
|
||||
this.features$.next(null);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import bytes from 'bytes';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { AuthService } from '../services/auth';
|
||||
import type { UserQuotaStore } from '../stores/user-quota';
|
||||
@@ -79,7 +79,7 @@ export class UserQuota extends Entity {
|
||||
return { quota, used };
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
const { quota, used } = data;
|
||||
this.quota$.next(quota);
|
||||
@@ -88,7 +88,6 @@ export class UserQuota extends Entity {
|
||||
this.quota$.next(null);
|
||||
this.used$.next(null);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, map, mergeMap } from 'rxjs';
|
||||
import { map, tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspaceServerService } from '../services/workspace-server';
|
||||
@@ -55,10 +55,9 @@ export class WorkspaceInvoices extends Entity {
|
||||
signal
|
||||
);
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.invoiceCount$.setValue(data.invoiceCount);
|
||||
this.pageInvoices$.setValue(data.invoices);
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspaceServerService } from '../services/workspace-server';
|
||||
@@ -123,7 +123,7 @@ export class WorkspaceSubscription extends Entity {
|
||||
};
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data && data.subscription && data.workspaceId && this.store) {
|
||||
this.store.setCachedWorkspaceSubscription(
|
||||
data.workspaceId,
|
||||
@@ -133,7 +133,6 @@ export class WorkspaceSubscription extends Entity {
|
||||
} else {
|
||||
this.subscription$.next(undefined);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
onStart,
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, mergeMap, switchMap } from 'rxjs';
|
||||
import { exhaustMap, switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { ValidatorProvider } from '../provider/validator';
|
||||
import type { FetchService } from './fetch';
|
||||
@@ -58,11 +58,10 @@ export class CaptchaService extends Service {
|
||||
}
|
||||
return { challenge: data.challenge, token: undefined };
|
||||
}).pipe(
|
||||
mergeMap(({ challenge, token }) => {
|
||||
tap(({ challenge, token }) => {
|
||||
this.verifyToken$.next(token);
|
||||
this.challenge$.next(challenge);
|
||||
this.resetAfter5min();
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => {
|
||||
@@ -83,11 +82,10 @@ export class CaptchaService extends Service {
|
||||
});
|
||||
return true;
|
||||
}).pipe(
|
||||
mergeMap(_ => {
|
||||
tap(_ => {
|
||||
this.challenge$.next(undefined);
|
||||
this.verifyToken$.next(undefined);
|
||||
this.isLoading$.next(false);
|
||||
return EMPTY;
|
||||
})
|
||||
);
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
import { EMPTY, switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { AcceptInviteStore } from '../stores/accept-invite';
|
||||
import type { InviteInfoStore } from '../stores/invite-info';
|
||||
@@ -36,9 +36,8 @@ export class InvitationService extends Service {
|
||||
return fromPromise(async () => {
|
||||
return await this.inviteInfoStore.getInviteInfo(inviteId);
|
||||
}).pipe(
|
||||
mergeMap(res => {
|
||||
tap(res => {
|
||||
this.inviteInfo$.setValue(res);
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry({
|
||||
count: 1,
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { catchError, EMPTY, exhaustMap, groupBy, mergeMap } from 'rxjs';
|
||||
import { catchError, EMPTY, exhaustMap, groupBy, mergeMap, tap } from 'rxjs';
|
||||
|
||||
import type { PublicUserStore } from '../stores/public-user';
|
||||
|
||||
@@ -98,10 +98,9 @@ export class PublicUserService extends Service {
|
||||
this.setError(id, error);
|
||||
return EMPTY;
|
||||
}),
|
||||
mergeMap(user => {
|
||||
tap(user => {
|
||||
this.setPublicUser(id, user);
|
||||
this.setError(id, null); // clear error
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => this.setLoading(id, true)),
|
||||
onComplete(() => this.setLoading(id, false))
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { exhaustMap, tap } from 'rxjs';
|
||||
|
||||
import type { SelfhostGenerateLicenseStore } from '../stores/selfhost-generate-license';
|
||||
|
||||
@@ -27,9 +27,8 @@ export class SelfhostGenerateLicenseService extends Service {
|
||||
return await this.store.generateKey(sessionId);
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(key => {
|
||||
tap(key => {
|
||||
this.licenseKey$.next(key);
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => {
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { SelfhostLicenseStore } from '../stores/selfhost-license';
|
||||
@@ -36,12 +36,10 @@ export class SelfhostLicenseService extends Service {
|
||||
return await this.store.getLicense(currentWorkspaceId, signal);
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
this.license$.next(data);
|
||||
}
|
||||
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$),
|
||||
onStart(() => this.isRevalidating$.next(true)),
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
Service,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { catchError, EMPTY, mergeMap } from 'rxjs';
|
||||
import { catchError, EMPTY, tap } from 'rxjs';
|
||||
|
||||
import type {
|
||||
UpdateUserSettingsInput,
|
||||
@@ -33,9 +33,8 @@ export class UserSettingsService extends Service {
|
||||
return this.store.getUserSettings();
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(settings => {
|
||||
tap(settings => {
|
||||
this.userSettings$.value = settings;
|
||||
return EMPTY;
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$.value = error;
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
SUPPORTED_LANGUAGES,
|
||||
} from '@affine/i18n';
|
||||
import { effect, Entity, fromPromise, LiveData } from '@toeverything/infra';
|
||||
import { catchError, EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { catchError, EMPTY, exhaustMap } from 'rxjs';
|
||||
|
||||
import type { GlobalCache } from '../../storage';
|
||||
|
||||
@@ -76,8 +76,7 @@ export class I18n extends Entity {
|
||||
logger.error('Failed to change language', error);
|
||||
|
||||
return EMPTY;
|
||||
}),
|
||||
mergeMap(() => EMPTY)
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
import { switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { TemplateDownloaderStore } from '../store/downloader';
|
||||
|
||||
@@ -24,9 +24,8 @@ export class TemplateDownloader extends Entity {
|
||||
readonly download = effect(
|
||||
switchMap(({ snapshotUrl }: { snapshotUrl: string }) => {
|
||||
return fromPromise(() => this.store.download(snapshotUrl)).pipe(
|
||||
mergeMap(({ data }) => {
|
||||
tap(({ data }) => {
|
||||
this.data$.next(data);
|
||||
return EMPTY;
|
||||
}),
|
||||
smartRetry(),
|
||||
catchErrorInto(this.error$),
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
onComplete,
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { catchError, EMPTY, mergeMap, Observable, switchMap } from 'rxjs';
|
||||
import { catchError, EMPTY, Observable, switchMap, tap } from 'rxjs';
|
||||
|
||||
import type { ReadwiseStore } from '../store/readwise';
|
||||
import type {
|
||||
@@ -129,9 +129,8 @@ export class ReadwiseCrawler extends Entity {
|
||||
abortController?.abort();
|
||||
};
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
this.data$.next(data);
|
||||
return EMPTY;
|
||||
}),
|
||||
catchError(err => {
|
||||
this.error$.next(err);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { clamp } from 'lodash-es';
|
||||
import { EMPTY, mergeMap, switchMap } from 'rxjs';
|
||||
import { mergeMap, switchMap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
|
||||
@@ -194,7 +194,6 @@ export class AudioMedia extends Entity<AudioSource> {
|
||||
`Calculate audio stats time: ${performance.now() - startTime}ms`
|
||||
);
|
||||
}),
|
||||
mergeMap(() => EMPTY),
|
||||
onStart(() => this.loading$.setValue(true)),
|
||||
onComplete(() => {
|
||||
this.loading$.setValue(false);
|
||||
|
||||
@@ -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$),
|
||||
|
||||
@@ -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$),
|
||||
|
||||
@@ -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$),
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { truncate } from 'lodash-es';
|
||||
import { EMPTY, map, mergeMap, of, switchMap, throttleTime } from 'rxjs';
|
||||
import { map, of, switchMap, tap, throttleTime } from 'rxjs';
|
||||
|
||||
import type { DocRecord, DocsService } from '../../doc';
|
||||
import type { DocDisplayMetaService } from '../../doc-display-meta';
|
||||
@@ -97,10 +97,9 @@ export class DocsQuickSearchSession
|
||||
);
|
||||
}
|
||||
return out.pipe(
|
||||
mergeMap((items: QuickSearchItem<'docs', DocsPayload>[]) => {
|
||||
tap((items: QuickSearchItem<'docs', DocsPayload>[]) => {
|
||||
this.items$.next(items);
|
||||
this.isQueryLoading$.next(false);
|
||||
return EMPTY;
|
||||
}),
|
||||
onStart(() => {
|
||||
this.items$.next([]);
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@toeverything/infra';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
import bytes from 'bytes';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspaceQuotaStore } from '../stores/quota';
|
||||
@@ -76,7 +76,7 @@ export class WorkspaceQuota extends Entity {
|
||||
return { quota: data, used: data.usedStorageQuota };
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
const { quota, used } = data;
|
||||
this.quota$.next(quota);
|
||||
@@ -85,7 +85,6 @@ export class WorkspaceQuota extends Entity {
|
||||
this.quota$.next(null);
|
||||
this.used$.next(null);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$, error => {
|
||||
logger.error('Failed to fetch workspace quota', error);
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, mergeMap } from 'rxjs';
|
||||
import { tap } from 'rxjs';
|
||||
|
||||
import type { GlobalCache } from '../../storage';
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
@@ -43,9 +43,8 @@ export class ShareDocsList extends Entity {
|
||||
);
|
||||
}).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(list => {
|
||||
tap(list => {
|
||||
this.cache.set('share-docs', list);
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$, err =>
|
||||
logger.error('revalidate share docs error', err)
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
onStart,
|
||||
smartRetry,
|
||||
} from '@toeverything/infra';
|
||||
import { EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { exhaustMap, tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceService } from '../../workspace';
|
||||
import type { WorkspaceShareSettingStore } from '../stores/share-setting';
|
||||
@@ -45,13 +45,12 @@ export class WorkspaceShareSetting extends Entity {
|
||||
)
|
||||
).pipe(
|
||||
smartRetry(),
|
||||
mergeMap(value => {
|
||||
tap(value => {
|
||||
if (value) {
|
||||
this.enableAi$.next(value.enableAi);
|
||||
this.enableUrlPreview$.next(value.enableUrlPreview);
|
||||
this.inviteLink$.next(value.inviteLink);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$, error => {
|
||||
logger.error('Failed to fetch enableUrlPreview', error);
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
Service,
|
||||
} from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { EMPTY, map, mergeMap, Observable, switchMap } from 'rxjs';
|
||||
import { map, Observable, switchMap, tap } from 'rxjs';
|
||||
import { type Doc as YDoc, encodeStateAsUpdate } from 'yjs';
|
||||
|
||||
import type { Server, ServersService } from '../../cloud';
|
||||
@@ -254,7 +254,7 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
})),
|
||||
};
|
||||
}).pipe(
|
||||
mergeMap(data => {
|
||||
tap(data => {
|
||||
if (data) {
|
||||
const { accountId, workspaces } = data;
|
||||
const sorted = workspaces.sort((a, b) => {
|
||||
@@ -270,7 +270,6 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
} else {
|
||||
this.workspaces$.next([]);
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchErrorInto(this.error$, err => {
|
||||
logger.error('error to revalidate cloud workspaces', err);
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
onStart,
|
||||
} from '@toeverything/infra';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import { catchError, EMPTY, exhaustMap, mergeMap } from 'rxjs';
|
||||
import { catchError, EMPTY, exhaustMap, tap } from 'rxjs';
|
||||
|
||||
import type { WorkspaceMetadata } from '../metadata';
|
||||
import type { WorkspaceFlavourProvider } from '../providers/flavour';
|
||||
@@ -76,11 +76,10 @@ export class WorkspaceProfile extends Entity<{ metadata: WorkspaceMetadata }> {
|
||||
return fromPromise(signal =>
|
||||
provider.getWorkspaceProfile(this.props.metadata.id, signal)
|
||||
).pipe(
|
||||
mergeMap(info => {
|
||||
tap(info => {
|
||||
if (info) {
|
||||
this.setProfile({ ...this.profile$.value, ...info });
|
||||
}
|
||||
return EMPTY;
|
||||
}),
|
||||
catchError(err => {
|
||||
logger.error(err);
|
||||
|
||||
Reference in New Issue
Block a user