Merge branch 'develop' of github.com:jaedb/Iris into develop

This commit is contained in:
James Barnsley
2020-03-12 08:32:08 +13:00
3 changed files with 59 additions and 31 deletions

View File

@ -18,14 +18,25 @@ class DiscoverCategory extends React.Component {
this.setWindowTitle(); this.setWindowTitle();
} }
componentWillReceiveProps(nextProps) { componentDidUpdate = ({
if (nextProps.match.params.id != this.props.match.params.id) { match: {
this.loadCategory(); params: {
} id: prevId,
},
},
category: prevCategory,
}) => {
const {
match: {
params: {
id,
},
},
category,
} = this.props;
if (!this.props.category && nextProps.category) { if (prevId !== id) this.loadCategory();
this.setWindowTitle(nextProps.category); if (!prevCategory && category) this.setWindowTitle(category);
}
} }
setWindowTitle(category = this.props.category) { setWindowTitle(category = this.props.category) {

View File

@ -158,11 +158,21 @@ class Discover extends React.Component {
} }
} }
componentWillReceiveProps(newProps, newState) { componentDiUpdate = ({
// New seeds via URL match: {
if (newProps.match.params.seeds != this.props.match.params.seeds) { params: {
this.handleURLSeeds(newProps.match.params.seeds); seeds: prevSeeds,
} },
},
}) => {
const {
match: {
params: {
seeds,
},
},
} = this.props;
if (prevSeeds !== seeds) this.handleURLSeeds(seeds);
} }
handleContextMenu(e) { handleContextMenu(e) {

View File

@ -55,35 +55,42 @@ class LibraryAlbums extends React.Component {
} }
} }
componentWillReceiveProps(newProps) { componentDidUpdate = ({
if (newProps.mopidy_connected && (newProps.source == 'all' || newProps.source == 'local')) { mopidy_connected: prev_mopidy_connected,
// We've just connected }) => {
if (!this.props.mopidy_connected) { const {
this.props.mopidyActions.getLibraryAlbums(); mopidy_connected,
} google_enabled,
spotify_enabled,
source,
mopidyActions,
googleActions,
spotifyActions,
mopidy_library_albums_status,
google_library_albums_status,
spotify_library_albums_status,
} = this.props;
if (mopidy_connected && (source == 'all' || source == 'local')) {
if (!prev_mopidy_connected) mopidyActions.getLibraryAlbums();
// Filter changed, but we haven't got this provider's library yet // Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'local' && newProps.mopidy_library_albums_status != 'finished' && newProps.mopidy_library_albums_status != 'started') { if (source !== 'all' && source !== 'local' && mopidy_library_albums_status !== 'finished' && mopidy_library_albums_status !== 'started') {
this.props.mopidyActions.getLibraryAlbums(); mopidyActions.getLibraryAlbums();
} }
} }
if (newProps.google_enabled && (newProps.source == 'all' || newProps.source == 'google')) { if (google_enabled && (newProps.source == 'all' || newProps.source == 'google')) {
// We've just been enabled (or detected as such)
if (!this.props.google_enabled) {
this.props.googleActions.getLibraryAlbums();
}
// Filter changed, but we haven't got this provider's library yet // Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'google' && newProps.google_library_albums_status != 'finished' && newProps.google_library_albums_status != 'started') { if (source !== 'all' && source !== 'google' && google_library_albums_status !== 'finished' && google_library_albums_status !== 'started') {
this.props.googleActions.getLibraryAlbums(); googleActions.getLibraryAlbums();
} }
} }
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')) { if (spotify_enabled && (source === 'all' || source === 'spotify')) {
// Filter changed, but we haven't got this provider's library yet // Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_albums_status != 'finished' && newProps.spotify_library_albums_status != 'started') { if (spotify_library_albums_status !== 'finished' && spotify_library_albums_status !== 'started') {
this.props.spotifyActions.getLibraryAlbums(); spotifyActions.getLibraryAlbums();
} }
} }
} }