Only fetch Spotify assets when Spotify enabled, fixes #316

This commit is contained in:
James Barnsley
2018-08-05 20:59:11 +12:00
parent 679cb1609c
commit f235a1c48c
7 changed files with 42 additions and 26 deletions

View File

@ -36,12 +36,12 @@ class LibraryAlbums extends React.Component{
componentDidMount(){
this.props.uiActions.setWindowTitle("Albums");
if (this.props.mopidy_library_albums_status != 'finished' && this.props.mopidy_library_albums_status != 'started' && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){
this.props.mopidyActions.getLibraryAlbums()
if (this.props.mopidy_connected && this.props.mopidy_library_albums_status != 'finished' && this.props.mopidy_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'local')){
this.props.mopidyActions.getLibraryAlbums();
}
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryAlbums()
if (this.props.spotify_enabled && this.props.spotify_library_albums_status != 'finished' && this.props.spotify_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryAlbums();
}
}
@ -59,7 +59,7 @@ class LibraryAlbums extends React.Component{
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')){
// 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'){
@ -210,7 +210,7 @@ class LibraryAlbums extends React.Component{
}
];
if (this.props.mopidy_uri_schemes.includes('spotify:')){
if (this.props.spotify_enabled){
source_options.push({
value: 'spotify',
label: 'Spotify'
@ -310,6 +310,7 @@ const mapStateToProps = (state, ownProps) => {
albums: state.core.albums,
mopidy_library_albums: state.mopidy.library_albums,
mopidy_library_albums_status: (state.ui.processes.MOPIDY_LIBRARY_ALBUMS_PROCESSOR !== undefined ? state.ui.processes.MOPIDY_LIBRARY_ALBUMS_PROCESSOR.status : null),
spotify_enabled: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('spotify:')),
spotify_library_albums: state.spotify.library_albums,
spotify_library_albums_status: (state.ui.processes.SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR !== undefined ? state.ui.processes.SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR.status : null),
view: state.ui.library_albums_view,

View File

@ -36,7 +36,7 @@ class LibraryArtists extends React.Component{
this.props.mopidyActions.getLibraryArtists();
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_enabled && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryArtists();
}
}
@ -55,7 +55,7 @@ class LibraryArtists extends React.Component{
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')){
// Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_artists_status != 'finished' && newProps.spotify_library_artists_status != 'started'){
@ -186,7 +186,7 @@ class LibraryArtists extends React.Component{
}
];
if (this.props.mopidy_uri_schemes.includes('spotify:')){
if (this.props.spotify_enabled){
source_options.push({
value: 'spotify',
label: 'Spotify'
@ -276,6 +276,7 @@ const mapStateToProps = (state, ownProps) => {
mopidy_uri_schemes: state.mopidy.uri_schemes,
mopidy_library_artists: state.mopidy.library_artists,
mopidy_library_artists_status: (state.ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR !== undefined ? state.ui.processes.MOPIDY_LIBRARY_ARTISTS_PROCESSOR.status : null),
spotify_enabled: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('spotify:')),
spotify_library_artists: state.spotify.library_artists,
spotify_library_artists_status: (state.ui.processes.SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR !== undefined ? state.ui.processes.SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR.status : null),
artists: state.core.artists,

View File

@ -37,7 +37,7 @@ class LibraryPlaylists extends React.Component{
this.props.mopidyActions.getLibraryPlaylists()
}
if (this.props.mopidy_uri_schemes.includes('spotify:') && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_enabled && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryPlaylists()
}
}
@ -57,7 +57,7 @@ class LibraryPlaylists extends React.Component{
}
}
if (newProps.mopidy_uri_schemes.includes('spotify:') && (newProps.source == 'all' || newProps.source == 'spotify')){
if (newProps.spotify_enabled && (newProps.source == 'all' || newProps.source == 'spotify')){
// Filter changed, but we haven't got this provider's library yet
if (newProps.spotify_library_playlists_status != 'finished' && newProps.spotify_library_playlists_status != 'started'){
@ -182,7 +182,7 @@ class LibraryPlaylists extends React.Component{
}
];
if (this.props.mopidy_uri_schemes.includes('spotify:')){
if (this.props.spotify_enabled){
source_options.push({
value: 'spotify',
label: 'Spotify'
@ -286,6 +286,7 @@ const mapStateToProps = (state, ownProps) => {
mopidy_uri_schemes: state.mopidy.uri_schemes,
mopidy_library_playlists: state.mopidy.library_playlists,
mopidy_library_playlists_status: (state.ui.processes.MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR !== undefined ? state.ui.processes.MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR.status : null),
spotify_enabled: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('spotify:')),
spotify_library_playlists: state.spotify.library_playlists,
spotify_library_playlists_status: (state.ui.processes.SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR !== undefined ? state.ui.processes.SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR.status : null),
load_queue: state.ui.load_queue,

View File

@ -24,7 +24,11 @@ class LibraryTracks extends React.Component{
componentDidMount(){
this.props.uiActions.setWindowTitle("Tracks");
if (this.props.library_tracks === undefined){
if (!this.props.spotify_enabled){
this.props.uiActions.createNotification({type: 'warning', content: 'Enable Spotify to browse tracks'});
}
if (this.props.spotify_enabled && this.props.library_tracks === undefined){
this.props.spotifyActions.getLibraryTracks();
}
}
@ -99,6 +103,7 @@ const mapStateToProps = (state, ownProps) => {
return {
load_queue: state.ui.load_queue,
tracks: state.core.tracks,
spotify_enabled: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('spotify:')),
library_tracks: state.spotify.library_tracks,
library_tracks_more: state.spotify.library_tracks_more
}