Lidarr/frontend/src/Store/Selectors/createProfileInUseSelector.js

25 lines
591 B
JavaScript
Raw Normal View History

2017-09-04 02:20:56 +00:00
import _ from 'lodash';
import { createSelector } from 'reselect';
import createAllArtistSelector from './createAllArtistSelector';
2017-09-04 02:20:56 +00:00
function createProfileInUseSelector(profileProp) {
return createSelector(
(state, { id }) => id,
createAllArtistSelector(),
(state) => state.settings.importLists.items,
(id, artist, lists) => {
2017-09-04 02:20:56 +00:00
if (!id) {
return false;
}
if (_.some(artist, { [profileProp]: id }) || _.some(lists, { [profileProp]: id })) {
return true;
}
return false;
2017-09-04 02:20:56 +00:00
}
);
}
export default createProfileInUseSelector;