Put switch map back instead of switch map to
This commit is contained in:
parent
84e7e2a81f
commit
a64a58b1ab
@ -5,7 +5,7 @@ import { UserService } from '@services/user.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { NotificationsService } from '@services/notifications.service';
|
||||
import { Notification } from '@red/domain';
|
||||
import { distinctUntilChanged, map, switchMapTo, tap } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators';
|
||||
import { BehaviorSubject, Observable, timer } from 'rxjs';
|
||||
import { AutoUnsubscribe, CHANGED_CHECK_INTERVAL, List, shareLast } from '@iqser/common-ui';
|
||||
|
||||
@ -54,7 +54,7 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
|
||||
|
||||
this.addSubscription = timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL)
|
||||
.pipe(
|
||||
switchMapTo(this._notificationsService.getNotificationsIfChanged(INCLUDE_SEEN)),
|
||||
switchMap(() => this._notificationsService.getNotificationsIfChanged(INCLUDE_SEEN)),
|
||||
tap(notifications => this._notifications$.next(notifications)),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
@ -4,7 +4,7 @@ import { DossiersDialogService } from '../../../../services/dossiers-dialog.serv
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, switchMapTo } from 'rxjs/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
|
||||
@ -34,7 +34,7 @@ export class DossierDetailsStatsComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.dossierStats$ = this._dossierStatsService.watch$(this.dossier.dossierId);
|
||||
this.deletedFilesCount$ = this._filesMapService.get$(this.dossier.dossierId).pipe(
|
||||
switchMapTo(this._filesService.getDeletedFilesFor(this.dossier.id)),
|
||||
switchMap(() => this._filesService.getDeletedFilesFor(this.dossier.id)),
|
||||
map(files => files.length),
|
||||
);
|
||||
this.dossierTemplateName = this._dossierTemplatesService.find(this.dossier.dossierTemplateId).name;
|
||||
|
||||
@ -17,7 +17,7 @@ import { FileUploadService } from '@upload-download/services/file-upload.service
|
||||
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
|
||||
import * as moment from 'moment';
|
||||
import { Observable, timer } from 'rxjs';
|
||||
import { filter, switchMapTo, tap } from 'rxjs/operators';
|
||||
import { filter, switchMap, tap } from 'rxjs/operators';
|
||||
import { convertFiles, Files, handleFileDrop } from '@utils/index';
|
||||
import {
|
||||
CHANGED_CHECK_INTERVAL,
|
||||
@ -141,9 +141,9 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
|
||||
|
||||
this.addSubscription = timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL)
|
||||
.pipe(
|
||||
switchMapTo(this._filesService.hasChanges$(this.dossierId)),
|
||||
switchMap(() => this._filesService.hasChanges$(this.dossierId)),
|
||||
filter(changed => changed),
|
||||
switchMapTo(this._reloadFiles()),
|
||||
switchMap(() => this._reloadFiles()),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
|
||||
@ -28,7 +28,6 @@ export class TableItemComponent implements OnChanges {
|
||||
}
|
||||
|
||||
private get _hasChanges$() {
|
||||
// I used switchMap instead of switchMapTo because I want to check dossierId every time
|
||||
return timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL).pipe(
|
||||
filter(() => !!this.dossier),
|
||||
switchMap(() => this.filesService.hasChanges$(this.dossier.dossierId)),
|
||||
|
||||
@ -20,7 +20,7 @@ import { ConfigService } from '../config.service';
|
||||
import { DossiersService } from '@services/entity-services/dossiers.service';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DossierTemplatesService } from '@services/entity-services/dossier-templates.service';
|
||||
import { switchMapTo, tap } from 'rxjs/operators';
|
||||
import { switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
templateUrl: './dossiers-listing-screen.component.html',
|
||||
@ -68,7 +68,7 @@ export class DossiersListingScreenComponent extends ListingComponent<Dossier> im
|
||||
|
||||
this.addSubscription = timer(CHANGED_CHECK_INTERVAL, CHANGED_CHECK_INTERVAL)
|
||||
.pipe(
|
||||
switchMapTo(this._dossiersService.loadAllIfChanged()),
|
||||
switchMap(() => this._dossiersService.loadAllIfChanged()),
|
||||
tap(() => this.computeAllFilters()),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
@ -535,7 +535,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
|
||||
private _subscribeToFileUpdates(): void {
|
||||
this.addSubscription = timer(0, 5000)
|
||||
.pipe(switchMapTo(this._filesService.reload(this.dossierId, this.fileId)))
|
||||
.pipe(switchMap(() => this._filesService.reload(this.dossierId, this.fileId)))
|
||||
.subscribe();
|
||||
this.addSubscription = this._filesMapService.fileReanalysed$
|
||||
.pipe(filter(file => file.fileId === this.fileId))
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
} from '@red/domain';
|
||||
import { interval, Observable } from 'rxjs';
|
||||
import { ConfigService } from '@services/config.service';
|
||||
import { filter, map, switchMapTo, tap, withLatestFrom } from 'rxjs/operators';
|
||||
import { filter, map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { EntitiesService, List, mapEach, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
@ -29,7 +29,7 @@ export class FileDownloadService extends EntitiesService<DownloadStatus, IDownlo
|
||||
.pipe(
|
||||
withLatestFrom(_userService.currentUser$),
|
||||
filter(([, user]) => user.isUser),
|
||||
switchMapTo(this.loadAll()),
|
||||
switchMap(() => this.loadAll()),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
@ -38,7 +38,7 @@ export class FileDownloadService extends EntitiesService<DownloadStatus, IDownlo
|
||||
return this.prepareDownload({
|
||||
fileIds,
|
||||
dossierId,
|
||||
}).pipe(switchMapTo(this.loadAll()));
|
||||
}).pipe(switchMap(() => this.loadAll()));
|
||||
}
|
||||
|
||||
loadAll(): Observable<DownloadStatus[]> {
|
||||
|
||||
@ -2,7 +2,7 @@ import { GenericService, HeadersConfiguration, List, QueryParam, RequiredParam,
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { switchMap, switchMapTo } from 'rxjs/operators';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { FilesService } from '@services/entity-services/files.service';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@ -20,7 +20,7 @@ export class FileManagementService extends GenericService<unknown> {
|
||||
|
||||
@Validate()
|
||||
delete(@RequiredParam() fileIds: List, @RequiredParam() dossierId: string) {
|
||||
return super._post(fileIds, `delete/${dossierId}`).pipe(switchMapTo(this._filesService.loadAll(dossierId)));
|
||||
return super._post(fileIds, `delete/${dossierId}`).pipe(switchMap(() => this._filesService.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
@ -28,12 +28,12 @@ export class FileManagementService extends GenericService<unknown> {
|
||||
const queryParams = fileIds.map<QueryParam>(id => ({ key: 'fileIds', value: id }));
|
||||
return super
|
||||
.delete({}, `delete/hard-delete/${dossierId}`, queryParams)
|
||||
.pipe(switchMapTo(this._dossierStatsService.getFor([dossierId])));
|
||||
.pipe(switchMap(() => this._dossierStatsService.getFor([dossierId])));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
restore(@RequiredParam() body: List, @RequiredParam() dossierId: string) {
|
||||
return this._post(body, `delete/restore/${dossierId}`).pipe(switchMapTo(this._filesService.loadAll(dossierId)));
|
||||
return this._post(body, `delete/restore/${dossierId}`).pipe(switchMap(() => this._filesService.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
downloadOriginalFile(dossierId: string, fileId: string, observe?: 'body', inline?: boolean, indicator?: string): Observable<Blob>;
|
||||
|
||||
@ -4,7 +4,7 @@ import { File, IFile } from '@red/domain';
|
||||
import { Observable } from 'rxjs';
|
||||
import { UserService } from '../user.service';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
import { map, mapTo, switchMap, switchMapTo, tap } from 'rxjs/operators';
|
||||
import { map, mapTo, switchMap, tap } from 'rxjs/operators';
|
||||
import { DossierStatsService } from '@services/entity-services/dossier-stats.service';
|
||||
|
||||
@Injectable({
|
||||
@ -38,13 +38,13 @@ export class FilesService extends EntitiesService<File, IFile> {
|
||||
@Validate()
|
||||
setUnassigned(@RequiredParam() fileIds: List, @RequiredParam() dossierId: string) {
|
||||
const url = `${this._defaultModelPath}/set-assignee/${dossierId}/bulk`;
|
||||
return this._post<unknown>(fileIds, url).pipe(switchMapTo(this.loadAll(dossierId)));
|
||||
return this._post<unknown>(fileIds, url).pipe(switchMap(() => this.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
setUnderApprovalFor(@RequiredParam() fileIds: List, @RequiredParam() dossierId: string, asigneeId: string) {
|
||||
const url = `${this._defaultModelPath}/under-approval/${dossierId}/bulk`;
|
||||
return this._post<unknown>(fileIds, url, [{ key: 'assigneeId', value: asigneeId }]).pipe(switchMapTo(this.loadAll(dossierId)));
|
||||
return this._post<unknown>(fileIds, url, [{ key: 'assigneeId', value: asigneeId }]).pipe(switchMap(() => this.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,9 @@ export class FilesService extends EntitiesService<File, IFile> {
|
||||
@Validate()
|
||||
setReviewerFor(@RequiredParam() filesIds: List, @RequiredParam() dossierId: string, assigneeId: string) {
|
||||
const url = `${this._defaultModelPath}/under-review/${dossierId}/bulk`;
|
||||
return this._post<unknown>(filesIds, url, [{ key: 'assigneeId', value: assigneeId }]).pipe(switchMapTo(this.loadAll(dossierId)));
|
||||
return this._post<unknown>(filesIds, url, [{ key: 'assigneeId', value: assigneeId }]).pipe(
|
||||
switchMap(() => this.loadAll(dossierId)),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,7 +64,7 @@ export class FilesService extends EntitiesService<File, IFile> {
|
||||
@Validate()
|
||||
setApprovedFor(@RequiredParam() filesIds: List, @RequiredParam() dossierId: string) {
|
||||
return this._post<unknown>(filesIds, `${this._defaultModelPath}/approved/${dossierId}/bulk`).pipe(
|
||||
switchMapTo(this.loadAll(dossierId)),
|
||||
switchMap(() => this.loadAll(dossierId)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ export class FilesService extends EntitiesService<File, IFile> {
|
||||
@Validate()
|
||||
setUnderReviewFor(@RequiredParam() filesIds: List, @RequiredParam() dossierId: string) {
|
||||
return this._post<unknown>(filesIds, `${this._defaultModelPath}/under-review/${dossierId}/bulk`).pipe(
|
||||
switchMapTo(this.loadAll(dossierId)),
|
||||
switchMap(() => this.loadAll(dossierId)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Injectable, Injector } from '@angular/core';
|
||||
import { GenericService, List, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
||||
import { IPageExclusionRequest } from '@red/domain';
|
||||
import { switchMap, switchMapTo } from 'rxjs/operators';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { FilesService } from './entity-services/files.service';
|
||||
|
||||
@Injectable({
|
||||
@ -14,12 +14,12 @@ export class ReanalysisService extends GenericService<unknown> {
|
||||
|
||||
@Validate()
|
||||
excludePages(@RequiredParam() body: IPageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._post(body, `exclude-pages/${dossierId}/${fileId}`).pipe(switchMapTo(this._filesService.reload(dossierId, fileId)));
|
||||
return this._post(body, `exclude-pages/${dossierId}/${fileId}`).pipe(switchMap(() => this._filesService.reload(dossierId, fileId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
includePages(@RequiredParam() body: IPageExclusionRequest, @RequiredParam() dossierId: string, @RequiredParam() fileId: string) {
|
||||
return this._post(body, `include-pages/${dossierId}/${fileId}`).pipe(switchMapTo(this._filesService.reload(dossierId, fileId)));
|
||||
return this._post(body, `include-pages/${dossierId}/${fileId}`).pipe(switchMap(() => this._filesService.reload(dossierId, fileId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
@ -29,7 +29,7 @@ export class ReanalysisService extends GenericService<unknown> {
|
||||
queryParams.push({ key: 'force', value: force });
|
||||
}
|
||||
|
||||
return this._post(fileIds, `reanalyze/${dossierId}/bulk`, queryParams).pipe(switchMapTo(this._filesService.loadAll(dossierId)));
|
||||
return this._post(fileIds, `reanalyze/${dossierId}/bulk`, queryParams).pipe(switchMap(() => this._filesService.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
@ -40,13 +40,13 @@ export class ReanalysisService extends GenericService<unknown> {
|
||||
}
|
||||
|
||||
return this._post({}, `toggle-analysis/${dossierId}/${fileId}`, queryParams).pipe(
|
||||
switchMapTo(this._filesService.loadAll(dossierId)),
|
||||
switchMap(() => this._filesService.loadAll(dossierId)),
|
||||
);
|
||||
}
|
||||
|
||||
@Validate()
|
||||
ocrFiles(@RequiredParam() body: List, @RequiredParam() dossierId: string) {
|
||||
return this._post(body, `ocr/reanalyze/${dossierId}/bulk`).pipe(switchMapTo(this._filesService.loadAll(dossierId)));
|
||||
return this._post(body, `ocr/reanalyze/${dossierId}/bulk`).pipe(switchMap(() => this._filesService.loadAll(dossierId)));
|
||||
}
|
||||
|
||||
@Validate()
|
||||
@ -56,6 +56,6 @@ export class ReanalysisService extends GenericService<unknown> {
|
||||
queryParams.push({ key: 'force', value: force });
|
||||
}
|
||||
|
||||
return this._post({}, `reanalyze/${dossierId}`, queryParams).pipe(switchMapTo(this._filesService.loadAll(dossierId)));
|
||||
return this._post({}, `reanalyze/${dossierId}`, queryParams).pipe(switchMap(() => this._filesService.loadAll(dossierId)));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user