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