Experimenting with filtered selectors (search)

This commit is contained in:
James Barnsley
2020-09-22 21:04:08 +12:00
parent ae83352dfb
commit d46ff41106
5 changed files with 98 additions and 70 deletions

View File

@ -40,9 +40,27 @@ const makeLibrarySelector = (uri) => createSelector(
},
);
const getMopidySearchResults = (state, props) => (
state.mopidy.search_results && state.mopidy.search_results[props.type]
);
const getSpotifySearchResults = (state, props) => (
state.spotify.search_results && state.spotify.search_results[props.type]
);
const makeSearchResultsSelector = () => createSelector(
[getMopidySearchResults, getSpotifySearchResults, getItems],
(mopidySearchResults, spotifySearchResults, items) => {
const uris = [
...mopidySearchResults || [],
...spotifySearchResults || [],
];
return indexToArray(items, uris);
},
);
export {
makeItemSelector,
makeLibrarySelector,
makeLoadingSelector,
makeSearchResultsSelector,
queueHistorySelector,
};