@@ -10,22 +10,39 @@ export default class FilterMonitor extends Component {
10
10
blacklist : PropTypes . array
11
11
} ;
12
12
13
+ isFiltered ( action ) {
14
+ return (
15
+ this . props . whitelist && this . props . whitelist . indexOf ( action ) !== - 1 ||
16
+ this . props . blacklist && this . props . blacklist . indexOf ( action ) === - 1
17
+ ) ;
18
+ }
19
+
13
20
render ( ) {
14
- const { whitelist, blacklist, monitorState, children, ...rest } = this . props ;
21
+ const {
22
+ whitelist, blacklist, monitorState, children,
23
+ stagedActionIds, computedStates,
24
+ ...rest
25
+ } = this . props ;
26
+ const filteredStagedActionIds = [ ] ;
27
+ const filteredComputedStates = [ ] ;
15
28
16
29
if ( whitelist || blacklist ) {
17
- let { stagedActionIds, actionsById } = rest ;
18
- stagedActionIds = stagedActionIds . filter ( id => {
19
- const action = actionsById [ id ] . action ;
20
- return (
21
- whitelist && whitelist . indexOf ( action . type ) !== - 1 ||
22
- blacklist && blacklist . indexOf ( action . type ) === - 1
23
- ) ;
30
+ stagedActionIds . forEach ( ( id , idx ) => {
31
+ if ( this . isFiltered ( rest . actionsById [ id ] . action . type ) ) {
32
+ filteredStagedActionIds . push ( id ) ;
33
+ filteredComputedStates . push ( computedStates [ idx ] ) ;
34
+ }
24
35
} ) ;
25
36
26
37
rest = {
27
38
...rest ,
28
- stagedActionIds : stagedActionIds
39
+ stagedActionIds : filteredStagedActionIds ,
40
+ computedStates : filteredComputedStates
41
+ } ;
42
+ } else {
43
+ rest = {
44
+ ...rest ,
45
+ stagedActionIds, computedStates
29
46
} ;
30
47
}
31
48
0 commit comments