2017-09-04 02:20:56 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
import createArtistSelector from 'Store/Selectors/createArtistSelector';
|
|
|
|
import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
|
|
|
|
import { executeCommand } from 'Store/Actions/commandActions';
|
|
|
|
import * as commandNames from 'Commands/commandNames';
|
|
|
|
import EpisodeSearchCell from './EpisodeSearchCell';
|
|
|
|
|
|
|
|
function createMapStateToProps() {
|
|
|
|
return createSelector(
|
2017-10-07 02:28:30 +00:00
|
|
|
(state, { albumId }) => albumId,
|
2017-09-04 02:20:56 +00:00
|
|
|
(state, { sceneSeasonNumber }) => sceneSeasonNumber,
|
|
|
|
createArtistSelector(),
|
|
|
|
createCommandsSelector(),
|
2017-10-07 22:38:31 +00:00
|
|
|
(albumId, sceneSeasonNumber, artist, commands) => {
|
2017-09-04 02:20:56 +00:00
|
|
|
const isSearching = _.some(commands, (command) => {
|
2017-10-29 01:44:06 +00:00
|
|
|
const episodeSearch = command.name === commandNames.ALBUM_SEARCH;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
if (!episodeSearch) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-07 02:28:30 +00:00
|
|
|
return command.body.albumIds.indexOf(albumId) > -1;
|
2017-09-04 02:20:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2017-10-07 22:38:31 +00:00
|
|
|
artistMonitored: artist.monitored,
|
|
|
|
artistType: artist.artistType,
|
2017-09-04 02:20:56 +00:00
|
|
|
isSearching
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createMapDispatchToProps(dispatch, props) {
|
|
|
|
return {
|
|
|
|
onSearchPress(name, path) {
|
|
|
|
dispatch(executeCommand({
|
2017-10-29 01:44:06 +00:00
|
|
|
name: commandNames.ALBUM_SEARCH,
|
2017-10-07 02:28:30 +00:00
|
|
|
albumIds: [props.albumId]
|
2017-09-04 02:20:56 +00:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(createMapStateToProps, createMapDispatchToProps)(EpisodeSearchCell);
|