Skip to content

Commit

Permalink
Remove user property from focusFilters state when no user selected
Browse files Browse the repository at this point in the history
Several pieces of code tested only for the presence of keys in `focusFilters` to
determine whether a focus filter was configured, rather than whether the
property was set to a "valid" value for that particular filter. The
`changeFocusModeUser` store action would always set this property, instead of
removing it when the passed user info was empty (logically meaning "no user is
focused").

Fixes #6109
  • Loading branch information
robertknight committed Jan 19, 2024
1 parent befe424 commit ccb0f77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/sidebar/store/modules/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,21 @@ function focusFiltersFromConfig(focusConfig: FocusConfig): Filters {

const reducers = {
CHANGE_FOCUS_MODE_USER(state: State, action: { user: FocusUserInfo }) {
const focusFilters = { ...state.focusFilters };
const { user } = focusFiltersFromConfig({ user: action.user });

const focusActive = new Set(state.focusActive);
if (user !== undefined) {
focusActive.add('user');
focusFilters.user = user;
} else {
focusActive.delete('user');
delete focusFilters.user;
}

return {
focusActive,
focusFilters: {
...state.focusFilters,
user,
},
focusFilters,
};
},

Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/store/modules/test/filters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('sidebar/store/modules/filters', () => {

const secondFilterState = getFiltersState();
assert.deepEqual(secondFilterState.focusActive, new Set());
assert.isUndefined(secondFilterState.focusFilters.user);
assert.notProperty(secondFilterState.focusFilters, 'user');
});
});

Expand Down

0 comments on commit ccb0f77

Please sign in to comment.