You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
import { connect } from 'react-redux';
|
|
import { push } from 'connected-react-router';
|
|
import { createSelector } from 'reselect';
|
|
import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector';
|
|
import createTagsSelector from 'Store/Selectors/createTagsSelector';
|
|
import ArtistSearchInput from './ArtistSearchInput';
|
|
|
|
function createCleanArtistSelector() {
|
|
return createSelector(
|
|
createAllArtistSelector(),
|
|
createTagsSelector(),
|
|
(allArtists, allTags) => {
|
|
return allArtists.map((artist) => {
|
|
const {
|
|
artistName,
|
|
sortName,
|
|
images,
|
|
foreignArtistId,
|
|
// alternateTitles,
|
|
tags = []
|
|
} = artist;
|
|
|
|
return {
|
|
artistName,
|
|
sortName,
|
|
foreignArtistId,
|
|
images,
|
|
tags: tags.map((id) => {
|
|
return allTags.find((tag) => tag.id === id);
|
|
})
|
|
};
|
|
});
|
|
}
|
|
);
|
|
}
|
|
|
|
function createMapStateToProps() {
|
|
return createSelector(
|
|
createCleanArtistSelector(),
|
|
(artists) => {
|
|
return {
|
|
artists
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
function createMapDispatchToProps(dispatch, props) {
|
|
return {
|
|
onGoToArtist(foreignArtistId) {
|
|
dispatch(push(`${window.Lidarr.urlBase}/artist/${foreignArtistId}`));
|
|
},
|
|
|
|
onGoToAddNewArtist(query) {
|
|
dispatch(push(`${window.Lidarr.urlBase}/add/new?term=${encodeURIComponent(query)}`));
|
|
}
|
|
};
|
|
}
|
|
|
|
export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistSearchInput);
|