mirror of
https://github.com/Radarr/Radarr
synced 2026-01-15 12:03:08 +01:00
* New: UI Updates, Tag manager, More custom filters * fixup! Fix ScanFixture Unit Tests * Fixed: Sentry Errors from UI don't have release, branch, environment * Changed: Bump Mobile Detect for New Device Detection * Fixed: Build on changes to package.json * fixup! Add MetadataProfile filter option * fixup! Tag Note, Blacklist, Manual Import * fixup: Remove connectSection * fixup: root folder comment
97 lines
2.4 KiB
JavaScript
97 lines
2.4 KiB
JavaScript
import _ from 'lodash';
|
|
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { createSelector } from 'reselect';
|
|
import { fetchTracks, setTracksSort, clearTracks } from 'Store/Actions/trackActions';
|
|
import { updateInteractiveImportItem } from 'Store/Actions/interactiveImportActions';
|
|
import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector';
|
|
import SelectTrackModalContent from './SelectTrackModalContent';
|
|
|
|
function createMapStateToProps() {
|
|
return createSelector(
|
|
createClientSideCollectionSelector('tracks'),
|
|
(tracks) => {
|
|
return tracks;
|
|
}
|
|
);
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
fetchTracks,
|
|
setTracksSort,
|
|
clearTracks,
|
|
updateInteractiveImportItem
|
|
};
|
|
|
|
class SelectTrackModalContentConnector extends Component {
|
|
|
|
//
|
|
// Lifecycle
|
|
|
|
componentDidMount() {
|
|
const {
|
|
artistId,
|
|
albumId
|
|
} = this.props;
|
|
|
|
this.props.fetchTracks({ artistId, albumId });
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
// This clears the tracks for the queue and hides the queue
|
|
// We'll need another place to store tracks for manual import
|
|
this.props.clearTracks();
|
|
}
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onSortPress = (sortKey, sortDirection) => {
|
|
this.props.setTracksSort({ sortKey, sortDirection });
|
|
}
|
|
|
|
onTracksSelect = (trackIds) => {
|
|
const tracks = _.reduce(this.props.items, (acc, item) => {
|
|
if (trackIds.indexOf(item.id) > -1) {
|
|
acc.push(item);
|
|
}
|
|
|
|
return acc;
|
|
}, []);
|
|
|
|
this.props.updateInteractiveImportItem({
|
|
id: this.props.id,
|
|
tracks: _.sortBy(tracks, 'trackNumber')
|
|
});
|
|
|
|
this.props.onModalClose(true);
|
|
}
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
return (
|
|
<SelectTrackModalContent
|
|
{...this.props}
|
|
onSortPress={this.onSortPress}
|
|
onTracksSelect={this.onTracksSelect}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
SelectTrackModalContentConnector.propTypes = {
|
|
id: PropTypes.number.isRequired,
|
|
artistId: PropTypes.number.isRequired,
|
|
albumId: PropTypes.number.isRequired,
|
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
fetchTracks: PropTypes.func.isRequired,
|
|
setTracksSort: PropTypes.func.isRequired,
|
|
clearTracks: PropTypes.func.isRequired,
|
|
updateInteractiveImportItem: PropTypes.func.isRequired,
|
|
onModalClose: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(SelectTrackModalContentConnector);
|