Skip to content

Commit baaf6a5

Browse files
committed
Filter computedStates along with stagedActionIds
Fix #4.
1 parent d427ff4 commit baaf6a5

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/FilterMonitor.js

+26-9
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,39 @@ export default class FilterMonitor extends Component {
1010
blacklist: PropTypes.array
1111
};
1212

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+
1320
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 = [];
1528

1629
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+
}
2435
});
2536

2637
rest = {
2738
...rest,
28-
stagedActionIds: stagedActionIds
39+
stagedActionIds: filteredStagedActionIds,
40+
computedStates: filteredComputedStates
41+
};
42+
} else {
43+
rest = {
44+
...rest,
45+
stagedActionIds, computedStates
2946
};
3047
}
3148

0 commit comments

Comments
 (0)