RED-6412, add detech changes, simplify methods, remove additional pipes.

This commit is contained in:
George 2023-03-30 15:46:38 +03:00
parent 75e54429fe
commit fdae158755

View File

@ -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<number, ListItem<AnnotationWrapper>[]>();
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<number, AnnotationWrapper[]>) {
const listItemsMap = new Map<number, ListItem<AnnotationWrapper>[]>();
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;
}
}