diff --git a/frontend/src/Activity/History/HistoryConnector.js b/frontend/src/Activity/History/HistoryConnector.js index c43c1aa43..2535fe7de 100644 --- a/frontend/src/Activity/History/HistoryConnector.js +++ b/frontend/src/Activity/History/HistoryConnector.js @@ -7,17 +7,22 @@ import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import * as historyActions from 'Store/Actions/historyActions'; import { fetchEpisodes, clearEpisodes } from 'Store/Actions/episodeActions'; +import { fetchTracks, clearTracks } from 'Store/Actions/trackActions'; import History from './History'; function createMapStateToProps() { return createSelector( (state) => state.history, (state) => state.episodes, - (history, episodes) => { + (state) => state.tracks, + (history, episodes, tracks) => { return { isAlbumsFetching: episodes.isFetching, isAlbumsPopulated: episodes.isPopulated, episodesError: episodes.error, + isTracksFetching: tracks.isFetching, + isTracksPopulated: tracks.isPopulated, + tracksError: tracks.error, ...history }; } @@ -27,7 +32,9 @@ function createMapStateToProps() { const mapDispatchToProps = { ...historyActions, fetchEpisodes, - clearEpisodes + clearEpisodes, + fetchTracks, + clearTracks }; class HistoryConnector extends Component { @@ -43,11 +50,17 @@ class HistoryConnector extends Component { componentDidUpdate(prevProps) { if (hasDifferentItems(prevProps.items, this.props.items)) { const albumIds = selectUniqueIds(this.props.items, 'albumId'); + const trackIds = selectUniqueIds(this.props.items, 'trackId'); if (albumIds.length) { this.props.fetchEpisodes({ albumIds }); } else { this.props.clearEpisodes(); } + if (trackIds.length) { + this.props.fetchTracks({ trackIds }); + } else { + this.props.clearTracks(); + } } } @@ -55,6 +68,7 @@ class HistoryConnector extends Component { unregisterPagePopulator(this.repopulate); this.props.clearHistory(); this.props.clearEpisodes(); + this.props.clearTracks(); } // @@ -136,7 +150,9 @@ HistoryConnector.propTypes = { setHistoryTableOption: PropTypes.func.isRequired, clearHistory: PropTypes.func.isRequired, fetchEpisodes: PropTypes.func.isRequired, - clearEpisodes: PropTypes.func.isRequired + clearEpisodes: PropTypes.func.isRequired, + fetchTracks: PropTypes.func.isRequired, + clearTracks: PropTypes.func.isRequired }; export default connect(createMapStateToProps, mapDispatchToProps)(HistoryConnector); diff --git a/frontend/src/Activity/History/HistoryRowConnector.js b/frontend/src/Activity/History/HistoryRowConnector.js index d8fab748d..9cafd2e95 100644 --- a/frontend/src/Activity/History/HistoryRowConnector.js +++ b/frontend/src/Activity/History/HistoryRowConnector.js @@ -5,6 +5,7 @@ import { createSelector } from 'reselect'; import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createEpisodeSelector from 'Store/Selectors/createEpisodeSelector'; +import createTrackSelector from 'Store/Selectors/createTrackSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import HistoryRow from './HistoryRow'; @@ -12,11 +13,13 @@ function createMapStateToProps() { return createSelector( createArtistSelector(), createEpisodeSelector(), + createTrackSelector(), createUISettingsSelector(), - (artist, album, uiSettings) => { + (artist, album, track, uiSettings) => { return { artist, album, + track, shortDateFormat: uiSettings.shortDateFormat, timeFormat: uiSettings.timeFormat }; diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index 618e98360..9f0a066ce 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -98,9 +98,9 @@ namespace NzbDrone.Core.History protected override SortBuilder GetPagedQuery(QueryBuilder query, PagingSpec pagingSpec) { - var baseQuery = query.Join(JoinType.Inner, h => h.Artist, (h, s) => h.ArtistId == s.Id) - .Join(JoinType.Inner, h => h.Album, (h, e) => h.AlbumId == e.Id) - .Join(JoinType.Left, h => h.Track, (h, e) => h.TrackId == e.Id); + var baseQuery = query.Join(JoinType.Inner, h => h.Artist, (h, a) => h.ArtistId == a.Id) + .Join(JoinType.Inner, h => h.Album, (h, r) => h.AlbumId == r.Id) + .Join(JoinType.Left, h => h.Track, (h, t) => h.TrackId == t.Id); return base.GetPagedQuery(baseQuery, pagingSpec); }