mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-06 04:52:21 -07:00
Fix: Not Loading/Showing Track on History Page
This commit is contained in:
parent
7e4a8c8ff7
commit
5f75c6046b
3 changed files with 26 additions and 7 deletions
|
@ -7,17 +7,22 @@ import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
|
||||||
import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
|
import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
|
||||||
import * as historyActions from 'Store/Actions/historyActions';
|
import * as historyActions from 'Store/Actions/historyActions';
|
||||||
import { fetchEpisodes, clearEpisodes } from 'Store/Actions/episodeActions';
|
import { fetchEpisodes, clearEpisodes } from 'Store/Actions/episodeActions';
|
||||||
|
import { fetchTracks, clearTracks } from 'Store/Actions/trackActions';
|
||||||
import History from './History';
|
import History from './History';
|
||||||
|
|
||||||
function createMapStateToProps() {
|
function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.history,
|
(state) => state.history,
|
||||||
(state) => state.episodes,
|
(state) => state.episodes,
|
||||||
(history, episodes) => {
|
(state) => state.tracks,
|
||||||
|
(history, episodes, tracks) => {
|
||||||
return {
|
return {
|
||||||
isAlbumsFetching: episodes.isFetching,
|
isAlbumsFetching: episodes.isFetching,
|
||||||
isAlbumsPopulated: episodes.isPopulated,
|
isAlbumsPopulated: episodes.isPopulated,
|
||||||
episodesError: episodes.error,
|
episodesError: episodes.error,
|
||||||
|
isTracksFetching: tracks.isFetching,
|
||||||
|
isTracksPopulated: tracks.isPopulated,
|
||||||
|
tracksError: tracks.error,
|
||||||
...history
|
...history
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -27,7 +32,9 @@ function createMapStateToProps() {
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
...historyActions,
|
...historyActions,
|
||||||
fetchEpisodes,
|
fetchEpisodes,
|
||||||
clearEpisodes
|
clearEpisodes,
|
||||||
|
fetchTracks,
|
||||||
|
clearTracks
|
||||||
};
|
};
|
||||||
|
|
||||||
class HistoryConnector extends Component {
|
class HistoryConnector extends Component {
|
||||||
|
@ -43,11 +50,17 @@ class HistoryConnector extends Component {
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
if (hasDifferentItems(prevProps.items, this.props.items)) {
|
if (hasDifferentItems(prevProps.items, this.props.items)) {
|
||||||
const albumIds = selectUniqueIds(this.props.items, 'albumId');
|
const albumIds = selectUniqueIds(this.props.items, 'albumId');
|
||||||
|
const trackIds = selectUniqueIds(this.props.items, 'trackId');
|
||||||
if (albumIds.length) {
|
if (albumIds.length) {
|
||||||
this.props.fetchEpisodes({ albumIds });
|
this.props.fetchEpisodes({ albumIds });
|
||||||
} else {
|
} else {
|
||||||
this.props.clearEpisodes();
|
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);
|
unregisterPagePopulator(this.repopulate);
|
||||||
this.props.clearHistory();
|
this.props.clearHistory();
|
||||||
this.props.clearEpisodes();
|
this.props.clearEpisodes();
|
||||||
|
this.props.clearTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -136,7 +150,9 @@ HistoryConnector.propTypes = {
|
||||||
setHistoryTableOption: PropTypes.func.isRequired,
|
setHistoryTableOption: PropTypes.func.isRequired,
|
||||||
clearHistory: PropTypes.func.isRequired,
|
clearHistory: PropTypes.func.isRequired,
|
||||||
fetchEpisodes: 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);
|
export default connect(createMapStateToProps, mapDispatchToProps)(HistoryConnector);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { createSelector } from 'reselect';
|
||||||
import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions';
|
import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions';
|
||||||
import createArtistSelector from 'Store/Selectors/createArtistSelector';
|
import createArtistSelector from 'Store/Selectors/createArtistSelector';
|
||||||
import createEpisodeSelector from 'Store/Selectors/createEpisodeSelector';
|
import createEpisodeSelector from 'Store/Selectors/createEpisodeSelector';
|
||||||
|
import createTrackSelector from 'Store/Selectors/createTrackSelector';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
import HistoryRow from './HistoryRow';
|
import HistoryRow from './HistoryRow';
|
||||||
|
|
||||||
|
@ -12,11 +13,13 @@ function createMapStateToProps() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
createArtistSelector(),
|
createArtistSelector(),
|
||||||
createEpisodeSelector(),
|
createEpisodeSelector(),
|
||||||
|
createTrackSelector(),
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(artist, album, uiSettings) => {
|
(artist, album, track, uiSettings) => {
|
||||||
return {
|
return {
|
||||||
artist,
|
artist,
|
||||||
album,
|
album,
|
||||||
|
track,
|
||||||
shortDateFormat: uiSettings.shortDateFormat,
|
shortDateFormat: uiSettings.shortDateFormat,
|
||||||
timeFormat: uiSettings.timeFormat
|
timeFormat: uiSettings.timeFormat
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,9 +98,9 @@ namespace NzbDrone.Core.History
|
||||||
|
|
||||||
protected override SortBuilder<History> GetPagedQuery(QueryBuilder<History> query, PagingSpec<History> pagingSpec)
|
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)
|
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, e) => h.AlbumId == e.Id)
|
.Join<History, Album>(JoinType.Inner, h => h.Album, (h, r) => h.AlbumId == r.Id)
|
||||||
.Join<History, Track>(JoinType.Left, h => h.Track, (h, e) => h.TrackId == e.Id);
|
.Join<History, Track>(JoinType.Left, h => h.Track, (h, t) => h.TrackId == t.Id);
|
||||||
|
|
||||||
return base.GetPagedQuery(baseQuery, pagingSpec);
|
return base.GetPagedQuery(baseQuery, pagingSpec);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue