Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
refactor(indexutils): remove omit with path
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed May 17, 2019
1 parent 2e8d630 commit 039afcb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('utility method for manipulating the search state', () => {
namespace: {},
});
});

it('get results', () => {
const searchResults = { results: { hits: ['some'] } };

Expand All @@ -235,6 +236,7 @@ describe('utility method for manipulating the search state', () => {
expect(results).toEqual({ hits: ['some'] });
});
});

describe('when there are multiple index', () => {
let context = { multiIndexContext: { targetedIndex: 'first' } };
it('refine with no namespace', () => {
Expand Down
14 changes: 12 additions & 2 deletions packages/react-instantsearch-core/src/core/indexUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { has, omit as lodashOmit, get } from 'lodash';
import { has, get } from 'lodash';
import { omit } from './utils';

export function getIndexId(context) {
Expand Down Expand Up @@ -269,5 +269,15 @@ function cleanUpValueWithMultiIndex({
};
}

return lodashOmit(searchState, `indices.${indexId}.${id}`);
if (indexSearchState) {
return {
...searchState,
indices: {
...searchState.indices,
[indexId]: omit(indexSearchState, [id]),
},
};
}

return searchState;
}

0 comments on commit 039afcb

Please sign in to comment.