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

@ -92,7 +92,8 @@ class Album extends React.Component{
}
inLibrary(){
return (this.props.library_albums && this.props.library_albums.indexOf(this.props.params.uri) > -1)
var library = helpers.uriSource(this.props.params.uri)+'_library_albums'
return (this.props[library] && this.props[library].indexOf(this.props.params.uri) > -1)
}
render(){
@ -172,7 +173,8 @@ const mapStateToProps = (state, ownProps) => {
artists: state.core.artists,
album: (state.core.albums && typeof(state.core.albums[ownProps.params.uri]) !== 'undefined' ? state.core.albums[ownProps.params.uri] : false ),
albums: state.core.albums,
library_albums: state.core.library_albums,
spotify_library_albums: state.spotify.library_albums,
local_library_albums: state.mopidy.library_albums,
spotify_authorized: state.spotify.authorization,
mopidy_connected: state.mopidy.connected
};

View File

@ -82,7 +82,8 @@ class Artist extends React.Component{
}
inLibrary(){
return (this.props.library_artists && this.props.library_artists.indexOf(this.props.params.uri) > -1)
var library = helpers.uriSource(this.props.params.uri)+'_library_artists'
return (this.props[library] && this.props[library].indexOf(this.props.params.uri) > -1)
}
renderSubViewMenu(){
@ -263,7 +264,8 @@ const mapStateToProps = (state, ownProps) => {
load_queue: state.ui.load_queue,
artist: (state.core.artists && typeof(state.core.artists[ownProps.params.uri]) !== 'undefined' ? state.core.artists[ownProps.params.uri] : false ),
artists: (state.core.artists ? state.core.artists : []),
library_artists: (state.core.library_artists ? state.core.library_artists : []),
spotify_library_artists: state.spotify.library_artists,
local_library_artists: state.mopidy.library_artists,
albums: (state.core.albums ? state.core.albums : []),
spotify_authorized: state.spotify.authorization,
mopidy_connected: state.mopidy.connected

View File

@ -105,7 +105,8 @@ class Playlist extends React.Component{
}
inLibrary(){
return (this.props.library_playlists && this.props.library_playlists.indexOf(this.props.params.uri) > -1)
var library = helpers.uriSource(this.props.params.uri)+'_library_playlists'
return (this.props[library] && this.props[library].indexOf(this.props.params.uri) > -1)
}
renderActions(){
@ -115,7 +116,7 @@ class Playlist extends React.Component{
return (
<div className="actions">
<button className="primary" onClick={ e => this.play() }>Play</button>
<button className="secondary" onClick={ e => this.props.uiActions.openModal('edit_playlist', { uri: this.props.playlist.uri, name: this.props.playlist.name }) }>Edit</button>
<button className="secondary" onClick={ e => this.props.uiActions.openModal('edit_playlist', { uri: this.props.params.uri, name: this.props.playlist.name }) }>Edit</button>
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
</div>
)
@ -125,7 +126,7 @@ class Playlist extends React.Component{
return (
<div className="actions">
<button className="primary" onClick={ e => this.play() }>Play</button>
<button className="secondary" onClick={ e => this.props.uiActions.openModal('edit_playlist', { uri: this.props.playlist.uri, name: this.props.playlist.name, is_public: this.props.playlist.public, description: this.props.playlist.description }) }>Edit</button>
<button className="secondary" onClick={ e => this.props.uiActions.openModal('edit_playlist', { uri: this.props.params.uri, name: this.props.playlist.name, is_public: this.props.playlist.public, description: this.props.playlist.description }) }>Edit</button>
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
</div>
)
@ -133,7 +134,7 @@ class Playlist extends React.Component{
return (
<div className="actions">
<button className="primary" onClick={ e => this.play() }>Play</button>
<FollowButton className="secondary" uri={this.props.playlist.uri} addText="Add to library" removeText="Remove from library" is_following={this.inLibrary()} />
<FollowButton className="secondary" uri={this.props.params.uri} addText="Add to library" removeText="Remove from library" is_following={this.inLibrary()} />
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
</div>
)
@ -214,8 +215,9 @@ const mapStateToProps = (state, ownProps) => {
return {
slim_mode: state.ui.slim_mode,
load_queue: state.ui.load_queue,
playlist: (state.core.playlists && typeof(state.core.playlists[uri]) !== 'undefined' ? state.core.playlists[uri] : false ),
library_playlists: state.core.library_playlists,
playlist: (state.core.playlists && state.core.playlists[uri] !== undefined ? state.core.playlists[uri] : false ),
spotify_library_playlists: state.spotify.library_playlists,
local_library_playlists: state.mopidy.library_playlists,
mopidy_connected: state.mopidy.connected,
spotify_authorized: state.spotify.authorization,
spotify_userid: state.spotify.me.id

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)),