Sensibly detecting Spotify availability by access_token; Only fetch playlists to add tracks to from relevant providers, fixes #539
This commit is contained in:
@ -46,11 +46,11 @@ class LibraryAlbums extends React.Component {
|
||||
this.props.mopidyActions.getLibraryAlbums();
|
||||
}
|
||||
|
||||
if (this.props.google_enabled && this.props.google_library_albums_status != 'finished' && this.props.google_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'google')) {
|
||||
if (this.props.google_available && this.props.google_library_albums_status != 'finished' && this.props.google_library_albums_status != 'started' && (this.props.source == 'all' || this.props.source == 'google')) {
|
||||
this.props.googleActions.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')) {
|
||||
if (this.props.spotify_available && 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();
|
||||
}
|
||||
}
|
||||
@ -60,8 +60,8 @@ class LibraryAlbums extends React.Component {
|
||||
}) => {
|
||||
const {
|
||||
mopidy_connected,
|
||||
google_enabled,
|
||||
spotify_enabled,
|
||||
google_available,
|
||||
spotify_available,
|
||||
source,
|
||||
mopidyActions,
|
||||
googleActions,
|
||||
@ -80,14 +80,14 @@ class LibraryAlbums extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
if (google_enabled && (source == 'all' || source == 'google')) {
|
||||
if (google_available && (source == 'all' || source == 'google')) {
|
||||
// Filter changed, but we haven't got this provider's library yet
|
||||
if (source !== 'all' && source !== 'google' && google_library_albums_status !== 'finished' && google_library_albums_status !== 'started') {
|
||||
googleActions.getLibraryAlbums();
|
||||
}
|
||||
}
|
||||
|
||||
if (spotify_enabled && (source === 'all' || source === 'spotify')) {
|
||||
if (spotify_available && (source === 'all' || source === 'spotify')) {
|
||||
// Filter changed, but we haven't got this provider's library yet
|
||||
if (spotify_library_albums_status !== 'finished' && spotify_library_albums_status !== 'started') {
|
||||
spotifyActions.getLibraryAlbums();
|
||||
@ -256,14 +256,14 @@ class LibraryAlbums extends React.Component {
|
||||
},
|
||||
];
|
||||
|
||||
if (this.props.spotify_enabled) {
|
||||
if (this.props.spotify_available) {
|
||||
source_options.push({
|
||||
value: 'spotify',
|
||||
label: 'Spotify',
|
||||
});
|
||||
}
|
||||
|
||||
if (this.props.google_enabled) {
|
||||
if (this.props.google_available) {
|
||||
source_options.push({
|
||||
value: 'google',
|
||||
label: 'Google',
|
||||
@ -363,10 +363,10 @@ 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),
|
||||
google_enabled: state.google.enabled,
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
google_library_albums: state.google.library_albums,
|
||||
google_library_albums_status: (state.ui.processes.GOOGLE_LIBRARY_ALBUMS_PROCESSOR !== undefined ? state.ui.processes.GOOGLE_LIBRARY_ALBUMS_PROCESSOR.status : null),
|
||||
spotify_enabled: state.spotify.enabled,
|
||||
spotify_available: state.spotify.access_token,
|
||||
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,
|
||||
|
||||
@ -44,11 +44,11 @@ class LibraryArtists extends React.Component {
|
||||
this.props.mopidyActions.getLibraryArtists();
|
||||
}
|
||||
|
||||
if (this.props.google_enabled && !this.props.google_library_artists && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'google')) {
|
||||
if (this.props.google_available && !this.props.google_library_artists && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'google')) {
|
||||
this.props.googleActions.getLibraryArtists();
|
||||
}
|
||||
|
||||
if (this.props.spotify_enabled && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
|
||||
if (this.props.spotify_available && this.props.spotify_library_artists_status != 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
|
||||
this.props.spotifyActions.getLibraryArtists();
|
||||
}
|
||||
}
|
||||
@ -59,8 +59,8 @@ class LibraryArtists extends React.Component {
|
||||
const {
|
||||
source,
|
||||
mopidy_connected,
|
||||
google_enabled,
|
||||
spotify_enabled,
|
||||
google_available,
|
||||
spotify_available,
|
||||
mopidyActions,
|
||||
googleActions,
|
||||
spotifyActions,
|
||||
@ -68,7 +68,7 @@ class LibraryArtists extends React.Component {
|
||||
google_library_artists,
|
||||
spotify_library_artists_status,
|
||||
} = this.props;
|
||||
|
||||
|
||||
if (mopidy_connected && (source === 'all' || source === 'local')) {
|
||||
if (!prev_mopidy_connected) mopidyActions.getLibraryArtists();
|
||||
|
||||
@ -77,13 +77,13 @@ class LibraryArtists extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
if (mopidy_connected && google_enabled && (source === 'all' || source === 'google')) {
|
||||
if (mopidy_connected && google_available && (source === 'all' || source === 'google')) {
|
||||
if (source !== 'all' && source !== 'google' && !google_library_artists) {
|
||||
googleActions.getLibraryArtists();
|
||||
}
|
||||
}
|
||||
|
||||
if (spotify_enabled && (source === 'all' || source === 'spotify')) {
|
||||
if (spotify_available && (source === 'all' || source === 'spotify')) {
|
||||
if (spotify_library_artists_status !== 'finished' && spotify_library_artists_status !== 'started') {
|
||||
spotifyActions.getLibraryArtists();
|
||||
}
|
||||
@ -232,14 +232,14 @@ class LibraryArtists extends React.Component {
|
||||
},
|
||||
];
|
||||
|
||||
if (this.props.spotify_enabled) {
|
||||
if (this.props.spotify_available) {
|
||||
source_options.push({
|
||||
value: 'spotify',
|
||||
label: 'Spotify',
|
||||
});
|
||||
}
|
||||
|
||||
if (this.props.google_enabled) {
|
||||
if (this.props.google_available) {
|
||||
source_options.push({
|
||||
value: 'google',
|
||||
label: 'Google',
|
||||
@ -323,20 +323,13 @@ class LibraryArtists extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export our component
|
||||
*
|
||||
* We also integrate our global store, using connect()
|
||||
* */
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
mopidy_connected: state.mopidy.connected,
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
mopidy_library_artists: state.mopidy.library_artists,
|
||||
google_enabled: state.google.enabled,
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
google_library_artists: state.google.library_artists,
|
||||
spotify_enabled: state.spotify.enabled,
|
||||
spotify_available: state.spotify.access_token,
|
||||
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,
|
||||
|
||||
@ -42,7 +42,7 @@ class LibraryPlaylists extends React.Component {
|
||||
this.props.mopidyActions.getLibraryPlaylists();
|
||||
}
|
||||
|
||||
if (this.props.spotify_enabled && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
|
||||
if (this.props.spotify_available && this.props.spotify_library_playlists_status !== 'finished' && (this.props.source == 'all' || this.props.source == 'spotify')) {
|
||||
this.props.spotifyActions.getLibraryPlaylists();
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ class LibraryPlaylists extends React.Component {
|
||||
source,
|
||||
mopidy_connected,
|
||||
mopidy_library_playlists,
|
||||
spotify_enabled,
|
||||
spotify_available,
|
||||
spotify_library_playlists_status,
|
||||
mopidyActions,
|
||||
spotifyActions,
|
||||
@ -68,7 +68,7 @@ class LibraryPlaylists extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
if (spotify_enabled && (source === 'all' || source === 'spotify')) {
|
||||
if (spotify_available && (source === 'all' || source === 'spotify')) {
|
||||
if (spotify_library_playlists_status !== 'finished' && spotify_library_playlists_status !== 'started') {
|
||||
spotifyActions.getLibraryPlaylists();
|
||||
}
|
||||
@ -190,7 +190,7 @@ class LibraryPlaylists extends React.Component {
|
||||
},
|
||||
];
|
||||
|
||||
if (this.props.spotify_enabled) {
|
||||
if (this.props.spotify_available) {
|
||||
source_options.push({
|
||||
value: 'spotify',
|
||||
label: 'Spotify',
|
||||
@ -296,7 +296,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_available: state.spotify.access_token,
|
||||
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,
|
||||
|
||||
@ -16,7 +16,7 @@ class LibraryTracks extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.uiActions.setWindowTitle('Tracks');
|
||||
|
||||
if (!this.props.spotify_me) {
|
||||
if (!this.props.spotify_available) {
|
||||
this.props.uiActions.createNotification({ level: 'warning', content: 'Enable Spotify to browse tracks' });
|
||||
} else if (this.props.library_tracks === undefined) {
|
||||
this.props.spotifyActions.getLibraryTracks();
|
||||
@ -94,7 +94,7 @@ Play all
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
load_queue: state.ui.load_queue,
|
||||
tracks: state.core.tracks,
|
||||
spotify_me: state.spotify.me,
|
||||
spotify_available: state.spotify.access_token,
|
||||
library_tracks: state.spotify.library_tracks,
|
||||
library_tracks_more: state.spotify.library_tracks_more,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user