From fdae158755901baa7aee95dcb52563b10a8f4fee Mon Sep 17 00:00:00 2001 From: George Date: Thu, 30 Mar 2023 15:46:38 +0300 Subject: [PATCH] RED-6412, add detech changes, simplify methods, remove additional pipes. --- .../file-workload/file-workload.component.ts | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index 6abef5a7f..48d42db25 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -12,6 +12,7 @@ import { IconButtonTypes, INestedFilter, IqserEventTarget, + log, shareDistinctLast, shareLast, } from '@iqser/common-ui'; @@ -158,15 +159,13 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy this.fileDataService.all$, primary$, secondary$, - this.multiSelectService.active$.pipe(distinctUntilChanged()), this.listingService.selected$, + this.multiSelectService.active$, ]).pipe( delay(0), - map( - ([annotations, primary, secondary, multiSelectInactive]) => - [this._filterAnnotations(annotations, primary, secondary), multiSelectInactive] as const, - ), - this._mapListItemsFromAnnotationWrapperArray(), + map(([annotations, primary, secondary]) => this._filterAnnotations(annotations, primary, secondary)), + map(annotations => this._mapListItemsFromAnnotationWrapperArray(annotations)), + tap(() => this._changeDetectorRef.detectChanges()), ); } @@ -469,23 +468,19 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy } } - private _mapListItemsFromAnnotationWrapperArray() { - return pipe( - map(([annotations, multiSelectActive]) => { - const listItemsMap = new Map[]>(); - if (!annotations) { - return listItemsMap; - } - [...annotations.keys()].forEach(key => { - const newValue = annotations.get(key).map(annotation => ({ - item: annotation, - isSelected: this.listingService.isSelected(annotation), - multiSelectActive, - })); - listItemsMap.set(key, newValue); - }); - return listItemsMap; - }), - ); + private _mapListItemsFromAnnotationWrapperArray(annotations: Map) { + const listItemsMap = new Map[]>(); + if (!annotations) { + return listItemsMap; + } + [...annotations.keys()].forEach(key => { + const newValue = annotations.get(key).map(annotation => ({ + item: annotation, + isSelected: this.listingService.isSelected(annotation), + multiSelectActive: this.multiSelectService.isActive, + })); + listItemsMap.set(key, newValue); + }); + return listItemsMap; } }