Processor cancelled vs finished; Re-run processor if incomplete during next render

This commit is contained in:
James Barnsley
2017-08-15 16:36:50 +12:00
parent 6f0088204b
commit f51e83099e
14 changed files with 156 additions and 106 deletions

View File

@ -30,11 +30,11 @@ class LibraryAlbums extends React.Component{
}
componentDidMount(){
if (!this.props.mopidy_library_albums && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){
if (this.props.mopidy_library_albums_status != 'finished' && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){
this.props.mopidyActions.getLibraryAlbums()
}
if (!this.props.spotify_library_albums && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_library_albums_status != 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryAlbums()
}
}
@ -48,7 +48,7 @@ class LibraryAlbums extends React.Component{
}
// 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){
if (this.props.source != 'all' && this.props.source != 'local' && newProps.mopidy_library_albums_status != 'finished'){
this.props.mopidyActions.getLibraryAlbums()
}
}
@ -61,7 +61,7 @@ class LibraryAlbums extends React.Component{
}
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && !newProps.spotify_library_albums){
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_albums_status != 'finished'){
this.props.spotifyActions.getLibraryAlbums()
}
}
@ -307,8 +307,10 @@ const mapStateToProps = (state, ownProps) => {
spotify_connected: state.spotify.connected,
load_queue: state.ui.load_queue,
albums: state.core.albums,
spotify_library_albums: state.spotify.library_albums,
mopidy_library_albums: state.mopidy.library_albums,
mopidy_library_albums_status: state.mopidy.library_albums_status,
spotify_library_albums: state.spotify.library_albums,
spotify_library_albums_status: state.spotify.library_albums_status,
view: state.ui.library_albums_view,
source: (state.ui.library_albums_source ? state.ui.library_albums_source : 'all'),
sort: (state.ui.library_albums_sort ? state.ui.library_albums_sort : 'name'),

View File

@ -27,11 +27,11 @@ class LibraryArtists extends React.Component{
}
componentDidMount(){
if (!this.props.mopidy_library_artists && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){
if (this.props.mopidy_library_artists_status != 'finished' && this.props.mopidy_connected && (this.props.source == 'all' || this.props.source == 'local')){
this.props.mopidyActions.getLibraryArtists()
}
if (!this.props.spotify_library_artists && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_library_artists_status != 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryArtists()
}
}
@ -45,7 +45,7 @@ class LibraryArtists extends React.Component{
}
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'local' && !newProps.mopidy_library_artists){
if (this.props.source != 'all' && this.props.source != 'local' && newProps.mopidy_library_artists_status != 'finished'){
this.props.mopidyActions.getLibraryArtists()
}
}
@ -58,9 +58,9 @@ class LibraryArtists extends React.Component{
}
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && !newProps.spotify_library_artists){
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_artists_status != 'finished'){
this.props.spotifyActions.getLibraryArtists()
}
}
}
}
@ -233,7 +233,9 @@ const mapStateToProps = (state, ownProps) => {
mopidy_connected: state.mopidy.connected,
spotify_connected: state.spotify.connected,
mopidy_library_artists: state.mopidy.library_artists,
mopidy_library_artists_status: state.mopidy.library_artists_status,
spotify_library_artists: state.spotify.library_artists,
spotify_library_artists_status: state.spotify.library_artists_status,
artists: state.core.artists,
source: (state.ui.library_artists_source ? state.ui.library_artists_source : 'all'),
sort: (state.ui.library_artists_sort ? state.ui.library_artists_sort : 'name'),

View File

@ -32,7 +32,7 @@ class LibraryPlaylists extends React.Component{
this.props.mopidyActions.getLibraryPlaylists()
}
if (!this.props.spotify_library_playlists && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
if (this.props.spotify_library_playlists_status !== 'finished' && this.props.spotify_connected && (this.props.source == 'all' || this.props.source == 'spotify')){
this.props.spotifyActions.getLibraryPlaylists()
}
}
@ -59,7 +59,7 @@ class LibraryPlaylists extends React.Component{
}
// Filter changed, but we haven't got this provider's library yet
if (this.props.source != 'all' && this.props.source != 'spotify' && !newProps.spotify_library_playlists){
if (this.props.source != 'all' && this.props.source != 'spotify' && newProps.spotify_library_playlists_status !== 'finished'){
this.props.spotifyActions.getLibraryPlaylists()
}
}
@ -259,7 +259,9 @@ const mapStateToProps = (state, ownProps) => {
mopidy_connected: state.mopidy.connected,
spotify_connected: state.spotify.connected,
mopidy_library_playlists: state.mopidy.library_playlists,
mopidy_library_playlists_status: state.mopidy.library_playlists_status,
spotify_library_playlists: state.spotify.library_playlists,
spotify_library_playlists_status: state.spotify.library_playlists_status,
slim_mode: state.ui.slim_mode,
load_queue: state.ui.load_queue,
me_id: (state.spotify.me ? state.spotify.me.id : (state.ui.config && state.ui.config.spotify_username ? state.ui.config.spotify_username : false)),