From 44e7445e0f537178b7945eb54537bf39ea10560e Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Fri, 18 Feb 2022 22:56:14 +0100 Subject: [PATCH] replacing mergeMap to switchMap in filter and sorting #287 --- .../app/ui/gallery/filter/filter.service.ts | 7 +- .../navigator.gallery.component.html | 22 +-- .../navigator/navigator.gallery.component.ts | 130 +++++++++--------- .../ui/gallery/navigator/sorting.service.ts | 6 +- 4 files changed, 83 insertions(+), 82 deletions(-) diff --git a/src/frontend/app/ui/gallery/filter/filter.service.ts b/src/frontend/app/ui/gallery/filter/filter.service.ts index 18586588..b207d3ba 100644 --- a/src/frontend/app/ui/gallery/filter/filter.service.ts +++ b/src/frontend/app/ui/gallery/filter/filter.service.ts @@ -2,7 +2,7 @@ import {Injectable} from '@angular/core'; import {BehaviorSubject, Observable} from 'rxjs'; import {PhotoDTO} from '../../../../../common/entities/PhotoDTO'; import {DirectoryContent} from '../content.service'; -import {map, mergeMap} from 'rxjs/operators'; +import {map, switchMap} from 'rxjs/operators'; export enum FilterRenderType { enum = 1, range = 2 @@ -90,18 +90,21 @@ export class FilterService { } public applyFilters(directoryContent: Observable): Observable { - return directoryContent.pipe(mergeMap((dirContent: DirectoryContent) => { + return directoryContent.pipe(switchMap((dirContent: DirectoryContent) => { + return this.selectedFilters.pipe(map((filters: SelectedFilter[]) => { if (!dirContent || !dirContent.media || !this.filtersVisible) { return dirContent; } + // clone, so the original won't get overwritten const c = { media: dirContent.media, directories: dirContent.directories, metaFile: dirContent.metaFile }; + for (const f of filters) { // get options diff --git a/src/frontend/app/ui/gallery/navigator/navigator.gallery.component.html b/src/frontend/app/ui/gallery/navigator/navigator.gallery.component.html index 4445d41b..3a9052e4 100644 --- a/src/frontend/app/ui/gallery/navigator/navigator.gallery.component.html +++ b/src/frontend/app/ui/gallery/navigator/navigator.gallery.component.html @@ -1,29 +1,29 @@