-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🌟 Add the ability to provide a custom merger
- Loading branch information
Showing
9 changed files
with
149 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/reducers/helpers/keysExplicitlyReferencedByListOperations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function keysExplicitlyReferencedByListOperations({ push = [], unshift = [], invalidate = [], merge = [] }) { | ||
return [ | ||
...push, | ||
...unshift, | ||
...invalidate, | ||
...merge.reduce((memo, mergerKeyPair) => memo.concat(mergerKeyPair[0]), []), | ||
]; | ||
} | ||
|
||
export default keysExplicitlyReferencedByListOperations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import keysExplicitlyReferencedByListOperations from './keysExplicitlyReferencedByListOperations'; | ||
import { getConfiguration } from '../../configuration'; | ||
import contains from '../../utils/list/contains'; | ||
|
||
/** | ||
* Processes a hash of ListOperations and returns the keys of the lists that it matches | ||
* @param {ListOperations} listOperations Hash of list operations to analyse | ||
* @param {Object} lists Collection of existing lists | ||
* @returns {string[]} Collection of list keys matching the list operations | ||
*/ | ||
function listKeysForItemKeySubstitution(listOperations, lists) { | ||
const keysExplicitlyReferenced = keysExplicitlyReferencedByListOperations(listOperations); | ||
|
||
if (contains(keysExplicitlyReferenced, getConfiguration().listWildcard)) { | ||
|
||
/** | ||
* If one of the list operations contained a wildcard, then we need to search all the lists | ||
*/ | ||
return Object.keys(lists); | ||
} | ||
|
||
/** | ||
* If no wildcard was used, we just return the keys of the lists that were explicitly referenced | ||
*/ | ||
return keysExplicitlyReferenced; | ||
} | ||
|
||
export default listKeysForItemKeySubstitution; |