@@ -14,19 +14,17 @@ limitations under the License.
14
14
==============================================================================*/
15
15
import { ChangeDetectionStrategy , Component } from '@angular/core' ;
16
16
import { Store } from '@ngrx/store' ;
17
- import { combineLatest , of } from 'rxjs' ;
18
- import { combineLatestWith , filter , map , switchMap } from 'rxjs/operators' ;
17
+ import { Observable } from 'rxjs' ;
18
+ import { combineLatestWith , filter , map } from 'rxjs/operators' ;
19
19
20
20
import { State } from '../../../app_state' ;
21
21
import {
22
22
getMetricsTagFilter ,
23
23
getNonEmptyCardIdsWithMetadata ,
24
24
} from '../../../selectors' ;
25
25
import { metricsTagFilterChanged } from '../../actions' ;
26
- import { compareTagNames } from '../utils' ;
27
-
28
- /** @typehack */ import * as _typeHackRxjs from 'rxjs' ;
29
26
import { getMetricsFilteredPluginTypes } from '../../store' ;
27
+ import { compareTagNames } from '../utils' ;
30
28
31
29
@Component ( {
32
30
selector : 'metrics-tag-filter' ,
@@ -43,9 +41,11 @@ import {getMetricsFilteredPluginTypes} from '../../store';
43
41
export class MetricsFilterInputContainer {
44
42
constructor ( private readonly store : Store < State > ) { }
45
43
46
- readonly tagFilter$ = this . store . select ( getMetricsTagFilter ) ;
44
+ readonly tagFilter$ : Observable < string > = this . store . select (
45
+ getMetricsTagFilter
46
+ ) ;
47
47
48
- readonly isTagFilterRegexValid$ = this . tagFilter$ . pipe (
48
+ readonly isTagFilterRegexValid$ : Observable < boolean > = this . tagFilter$ . pipe (
49
49
map ( ( tagFilterString ) => {
50
50
try {
51
51
// tslint:disable-next-line:no-unused-expression Check for validity of filter.
@@ -57,7 +57,7 @@ export class MetricsFilterInputContainer {
57
57
} )
58
58
) ;
59
59
60
- readonly completions$ = this . store
60
+ readonly completions$ : Observable < string [ ] > = this . store
61
61
. select ( getNonEmptyCardIdsWithMetadata )
62
62
. pipe (
63
63
combineLatestWith ( this . store . select ( getMetricsFilteredPluginTypes ) ) ,
@@ -68,12 +68,10 @@ export class MetricsFilterInputContainer {
68
68
} )
69
69
. map ( ( { tag} ) => tag ) ;
70
70
} ) ,
71
- switchMap ( ( cardList ) => {
72
- return combineLatest ( [
73
- of ( cardList ) ,
74
- this . store . select ( getMetricsTagFilter ) ,
75
- ] ) ;
76
- } ) ,
71
+ // De-duplicate using Set since Image cards has a notion of Sample and
72
+ // the same `run` and `tag` can appear more than once.
73
+ map ( ( tags ) => [ ...new Set ( tags ) ] ) ,
74
+ combineLatestWith ( this . store . select ( getMetricsTagFilter ) ) ,
77
75
map < [ string [ ] , string ] , [ string [ ] , RegExp | null ] > (
78
76
( [ tags , tagFilter ] ) => {
79
77
try {
0 commit comments