Skip to content

Commit 51b3220

Browse files
committed
Fix filtering
Fix #245.
1 parent e1b6530 commit 51b3220

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/app/api/filters.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export function startingFrom(
9696
const index = stagedActionIds.indexOf(sendingActionId);
9797
if (index === -1) return state;
9898

99+
const shouldFilter = predicate || localFilter ||
100+
window.devToolsOptions.filter !== FilterState.DO_NOT_FILTER;
101+
const filteredStagedActionIds = shouldFilter ? [0] : stagedActionIds;
99102
const actionsById = state.actionsById;
100103
const computedStates = state.computedStates;
101104
const newActionsById = {};
@@ -104,13 +107,20 @@ export function startingFrom(
104107
let currAction;
105108
let currState;
106109

107-
for (let i = index; i < stagedActionIds.length; i++) {
110+
for (let i = shouldFilter ? 1 : index; i < stagedActionIds.length; i++) {
108111
key = stagedActionIds[i];
109112
currAction = actionsById[key];
110113
currState = computedStates[i];
111-
if (predicate && !predicate(currState, currAction) || isFiltered(currAction, localFilter)) {
112-
continue;
114+
115+
if (shouldFilter) {
116+
if (
117+
predicate && !predicate(currState.state, currAction.action) ||
118+
isFiltered(currAction.action, localFilter)
119+
) continue;
120+
filteredStagedActionIds.push(key);
121+
if (i < index) continue;
113122
}
123+
114124
newActionsById[key] = !actionSanitizer ? currAction :
115125
{ ...currAction, action: actionSanitizer(currAction, key) };
116126
newComputedStates.push(
@@ -123,7 +133,7 @@ export function startingFrom(
123133
return {
124134
actionsById: newActionsById,
125135
computedStates: newComputedStates,
126-
stagedActionIds,
136+
stagedActionIds: filteredStagedActionIds,
127137
currentStateIndex: state.currentStateIndex,
128138
nextActionId: state.nextActionId
129139
};

0 commit comments

Comments
 (0)