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.
68 lines
1.7 KiB
68 lines
1.7 KiB
import _ from 'lodash';
|
|
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { createSelector } from 'reselect';
|
|
import * as commandNames from 'Commands/commandNames';
|
|
import { executeCommand } from 'Store/Actions/commandActions';
|
|
import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector';
|
|
import RetagArtistModalContent from './RetagArtistModalContent';
|
|
|
|
function createMapStateToProps() {
|
|
return createSelector(
|
|
(state, { artistIds }) => artistIds,
|
|
createAllArtistSelector(),
|
|
(artistIds, allArtists) => {
|
|
const artist = _.intersectionWith(allArtists, artistIds, (s, id) => {
|
|
return s.id === id;
|
|
});
|
|
|
|
const sortedArtist = _.orderBy(artist, 'sortName');
|
|
const artistNames = _.map(sortedArtist, 'artistName');
|
|
|
|
return {
|
|
artistNames
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
executeCommand
|
|
};
|
|
|
|
class RetagArtistModalContentConnector extends Component {
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onRetagArtistPress = () => {
|
|
this.props.executeCommand({
|
|
name: commandNames.RETAG_ARTIST,
|
|
artistIds: this.props.artistIds
|
|
});
|
|
|
|
this.props.onModalClose(true);
|
|
};
|
|
|
|
//
|
|
// Render
|
|
|
|
render(props) {
|
|
return (
|
|
<RetagArtistModalContent
|
|
{...this.props}
|
|
onRetagArtistPress={this.onRetagArtistPress}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
RetagArtistModalContentConnector.propTypes = {
|
|
artistIds: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
onModalClose: PropTypes.func.isRequired,
|
|
executeCommand: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(RetagArtistModalContentConnector);
|