Fix: Not Loading/Showing Track on History Page

pull/147/head
Qstick 7 years ago
parent 7e4a8c8ff7
commit 5f75c6046b

@ -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);

@ -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
};

@ -98,9 +98,9 @@ namespace NzbDrone.Core.History
protected override SortBuilder<History> GetPagedQuery(QueryBuilder<History> query, PagingSpec<History> pagingSpec)
{
var baseQuery = query.Join<History, Artist>(JoinType.Inner, h => h.Artist, (h, s) => h.ArtistId == s.Id)
.Join<History, Album>(JoinType.Inner, h => h.Album, (h, e) => h.AlbumId == e.Id)
.Join<History, Track>(JoinType.Left, h => h.Track, (h, e) => h.TrackId == e.Id);
var baseQuery = query.Join<History, Artist>(JoinType.Inner, h => h.Artist, (h, a) => h.ArtistId == a.Id)
.Join<History, Album>(JoinType.Inner, h => h.Album, (h, r) => h.AlbumId == r.Id)
.Join<History, Track>(JoinType.Left, h => h.Track, (h, t) => h.TrackId == t.Id);
return base.GetPagedQuery(baseQuery, pagingSpec);
}

Loading…
Cancel
Save