From 04434f5c55f8cc8c90892b9d78a28d57eafef4fa Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Sun, 9 Jun 2019 09:16:31 +0200 Subject: [PATCH] [redux-devtools-inspector]: filter - use '!' to negate query --- .../src/ActionList.jsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/redux-devtools-inspector/src/ActionList.jsx b/packages/redux-devtools-inspector/src/ActionList.jsx index 66ce8a3b..7f6f6236 100644 --- a/packages/redux-devtools-inspector/src/ActionList.jsx +++ b/packages/redux-devtools-inspector/src/ActionList.jsx @@ -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 (