[redux-devtools-inspector]: filter - use '!' to negate query

This commit is contained in:
Adam Borowski 2019-06-09 09:16:31 +02:00
parent 03d1448dc3
commit 04434f5c55

View File

@ -94,13 +94,19 @@ export default class ActionList extends Component {
onJumpToState
} = this.props;
const lowerSearchValue = searchValue && searchValue.toLowerCase();
const filteredActionIds = searchValue
? actionIds.filter(
id =>
actions[id].action.type.toLowerCase().indexOf(lowerSearchValue) !==
-1
)
: actionIds;
const shouldMatchNegative = lowerSearchValue && lowerSearchValue.indexOf('!') === 0;
const query = shouldMatchNegative ? lowerSearchValue.substring(1) : lowerSearchValue;
const filterFunction = id => {
const actionIndex = actions[id].action.type.toLowerCase().indexOf(query);
if (shouldMatchNegative) {
return actionIndex === -1;
}
return actionIndex !== -1;
};
const filteredActionIds = searchValue ? actionIds.filter(filterFunction) : actionIds;
return (
<div