Processor cancelled vs finished; Re-run processor if incomplete during next render
This commit is contained in:
@ -200,36 +200,6 @@ export default function reducer(core = {}, action){
|
|||||||
|
|
||||||
return Object.assign({}, core, { albums: albums });
|
return Object.assign({}, core, { albums: albums });
|
||||||
|
|
||||||
case 'LIBRARY_ALBUMS_LOADED':
|
|
||||||
var library_albums = []
|
|
||||||
if (core.library_albums) library_albums = Object.assign([], core.library_albums)
|
|
||||||
|
|
||||||
return Object.assign({}, core, {
|
|
||||||
library_albums: helpers.removeDuplicates([...library_albums, ...action.uris]),
|
|
||||||
library_albums_more: (action.more ? action.more : null),
|
|
||||||
library_albums_total: (action.total ? action.total : null),
|
|
||||||
library_albums_started: (action.started ? action.started : null),
|
|
||||||
});
|
|
||||||
|
|
||||||
case 'ALBUM_LIBRARY_CHECK':
|
|
||||||
var items = Object.assign([], core.library_albums)
|
|
||||||
|
|
||||||
// add/remove library reference
|
|
||||||
var index = items.indexOf(action.key)
|
|
||||||
|
|
||||||
// removing existing
|
|
||||||
if (index > -1 && !action.in_library){
|
|
||||||
items.splice(index, 1)
|
|
||||||
} else if (index < 0 && action.in_library){
|
|
||||||
items.push(action.key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.assign({}, core, { library_albums: items });
|
|
||||||
|
|
||||||
case 'LOCAL_ALBUMS_LOADED':
|
|
||||||
if (!action.uris) return Object.assign({}, core, { local_albums: null });
|
|
||||||
return Object.assign({}, core, { local_albums: action.uris });
|
|
||||||
|
|
||||||
case 'NEW_RELEASES_LOADED':
|
case 'NEW_RELEASES_LOADED':
|
||||||
if (!action.uris){
|
if (!action.uris){
|
||||||
return Object.assign({}, core, {
|
return Object.assign({}, core, {
|
||||||
@ -304,36 +274,6 @@ export default function reducer(core = {}, action){
|
|||||||
artists[action.key] = artist
|
artists[action.key] = artist
|
||||||
return Object.assign({}, core, { artists: artists });
|
return Object.assign({}, core, { artists: artists });
|
||||||
|
|
||||||
case 'LIBRARY_ARTISTS_LOADED':
|
|
||||||
var library_artists = []
|
|
||||||
if (core.library_artists) library_artists = Object.assign([], core.library_artists)
|
|
||||||
|
|
||||||
return Object.assign({}, core, {
|
|
||||||
library_artists: helpers.removeDuplicates([...library_artists, ...action.uris]),
|
|
||||||
library_artists_more: action.more,
|
|
||||||
library_artists_total: action.total,
|
|
||||||
library_artists_started: true
|
|
||||||
});
|
|
||||||
|
|
||||||
case 'ARTIST_LIBRARY_CHECK':
|
|
||||||
var items = Object.assign([], core.library_artists)
|
|
||||||
|
|
||||||
// add/remove library reference
|
|
||||||
var index = items.indexOf(action.key)
|
|
||||||
|
|
||||||
// removing existing
|
|
||||||
if (index > -1 && !action.in_library){
|
|
||||||
items.splice(index, 1)
|
|
||||||
} else if (index < 0 && action.in_library){
|
|
||||||
items.push(action.key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.assign({}, core, { library_artists: items });
|
|
||||||
|
|
||||||
case 'LOCAL_ARTISTS_LOADED':
|
|
||||||
if (!action.uris) return Object.assign({}, core, { local_artists: null });
|
|
||||||
return Object.assign({}, core, { local_artists: action.uris });
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User profiles
|
* User profiles
|
||||||
@ -532,21 +472,6 @@ export default function reducer(core = {}, action){
|
|||||||
library_playlists_started: true
|
library_playlists_started: true
|
||||||
});
|
});
|
||||||
|
|
||||||
case 'PLAYLIST_LIBRARY_CHECK':
|
|
||||||
var items = Object.assign([], core.library_playlists)
|
|
||||||
|
|
||||||
// add/remove library reference
|
|
||||||
var index = items.indexOf(action.key)
|
|
||||||
|
|
||||||
// removing existing
|
|
||||||
if (index > -1 && !action.in_library){
|
|
||||||
items.splice(index, 1)
|
|
||||||
} else if (index < 0 && action.in_library){
|
|
||||||
items.push(action.key)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.assign({}, core, { library_playlists: items });
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Genres
|
* Genres
|
||||||
|
|||||||
@ -852,6 +852,9 @@ const MopidyMiddleware = (function(){
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
case 'MOPIDY_GET_LIBRARY_ALBUMS':
|
case 'MOPIDY_GET_LIBRARY_ALBUMS':
|
||||||
|
|
||||||
|
store.dispatch({type: 'MOPIDY_LIBRARY_ALBUMS_CLEAR'})
|
||||||
|
|
||||||
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=album' } )
|
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=album' } )
|
||||||
.then( response => {
|
.then( response => {
|
||||||
if (response.length <= 0) return
|
if (response.length <= 0) return
|
||||||
@ -872,7 +875,7 @@ const MopidyMiddleware = (function(){
|
|||||||
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ALBUMS_PROCESSOR']
|
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ALBUMS_PROCESSOR']
|
||||||
|
|
||||||
if (processor.cancelling){
|
if (processor.cancelling){
|
||||||
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
|
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1003,6 +1006,9 @@ const MopidyMiddleware = (function(){
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
case 'MOPIDY_GET_LIBRARY_ARTISTS':
|
||||||
|
|
||||||
|
store.dispatch({type: 'MOPIDY_LIBRARY_ARTISTS_CLEAR'})
|
||||||
|
|
||||||
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
|
instruct( socket, store, 'library.browse', { uri: 'local:directory?type=artist' } )
|
||||||
.then( response => {
|
.then( response => {
|
||||||
if (response.length <= 0) return
|
if (response.length <= 0) return
|
||||||
@ -1024,7 +1030,7 @@ const MopidyMiddleware = (function(){
|
|||||||
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR']
|
var processor = store.getState().ui.processes['MOPIDY_LIBRARY_ARTISTS_PROCESSOR']
|
||||||
|
|
||||||
if (processor.cancelling){
|
if (processor.cancelling){
|
||||||
store.dispatch(uiActions.processFinished('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
store.dispatch(uiActions.processCancelled('MOPIDY_LIBRARY_ARTISTS_PROCESSOR'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -151,6 +151,35 @@ export default function reducer(mopidy = {}, action){
|
|||||||
}
|
}
|
||||||
return Object.assign({}, mopidy, { library_albums: uris })
|
return Object.assign({}, mopidy, { library_albums: uris })
|
||||||
|
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_PLAYLISTS_CLEAR':
|
||||||
|
return Object.assign({}, mopidy, { library_playlists: [] })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ARTISTS_CLEAR':
|
||||||
|
return Object.assign({}, mopidy, { library_artists: [] })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ALBUMS_CLEAR':
|
||||||
|
return Object.assign({}, mopidy, { library_albums: [] })
|
||||||
|
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, mopidy, { library_playlists_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_PLAYLISTS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, mopidy, { library_playlists_status: 'finished' })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, mopidy, { library_artists_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ARTISTS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, mopidy, { library_artists_status: 'finished' })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, mopidy, { library_albums_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, mopidy, { library_albums_status: 'finished' })
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return mopidy
|
return mopidy
|
||||||
}
|
}
|
||||||
|
|||||||
@ -597,10 +597,10 @@ export function following(uri, method = 'GET'){
|
|||||||
if( typeof(is_following) === 'object' ) is_following = is_following[0]
|
if( typeof(is_following) === 'object' ) is_following = is_following[0]
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: asset_name.toUpperCase()+'_LIBRARY_CHECK',
|
type: 'SPOTIFY_LIBRARY_'+asset_name.toUpperCase()+'_CHECK',
|
||||||
key: uri,
|
key: uri,
|
||||||
in_library: is_following
|
in_library: is_following
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1298,6 +1298,7 @@ export function reorderPlaylistTracks( uri, range_start, range_length, insert_be
|
|||||||
|
|
||||||
export function getLibraryPlaylists(){
|
export function getLibraryPlaylists(){
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
dispatch({type: 'SPOTIFY_LIBRARY_PLAYLISTS_CLEAR'})
|
||||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR','Loading Spotify playlists', {next: 'me/playlists?limit=50'}))
|
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR','Loading Spotify playlists', {next: 'me/playlists?limit=50'}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1317,7 +1318,7 @@ export function getLibraryPlaylistsProcessor(data){
|
|||||||
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR']
|
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR']
|
||||||
|
|
||||||
if (processor.cancelling){
|
if (processor.cancelling){
|
||||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR'))
|
dispatch(uiActions.processCancelled('SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1343,6 +1344,7 @@ export function getLibraryPlaylistsProcessor(data){
|
|||||||
|
|
||||||
export function getLibraryArtists(){
|
export function getLibraryArtists(){
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
dispatch({type: 'SPOTIFY_LIBRARY_ARTISTS_CLEAR'})
|
||||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR','Loading Spotify artists', {next: 'me/following?type=artist&limit=50'}))
|
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR','Loading Spotify artists', {next: 'me/following?type=artist&limit=50'}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1362,7 +1364,7 @@ export function getLibraryArtistsProcessor(data){
|
|||||||
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR']
|
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR']
|
||||||
|
|
||||||
if (processor.cancelling){
|
if (processor.cancelling){
|
||||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR'))
|
dispatch(uiActions.processCancelled('SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1388,6 +1390,7 @@ export function getLibraryArtistsProcessor(data){
|
|||||||
|
|
||||||
export function getLibraryAlbums(){
|
export function getLibraryAlbums(){
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
|
dispatch({type: 'SPOTIFY_LIBRARY_ALBUMS_CLEAR'})
|
||||||
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR','Loading Spotify albums', {next: 'me/albums?limit=50'}))
|
dispatch(uiActions.startProcess('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR','Loading Spotify albums', {next: 'me/albums?limit=50'}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1407,7 +1410,7 @@ export function getLibraryAlbumsProcessor(data){
|
|||||||
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR']
|
var processor = getState().ui.processes['SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR']
|
||||||
|
|
||||||
if (processor.cancelling){
|
if (processor.cancelling){
|
||||||
dispatch(uiActions.processFinished('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR'))
|
dispatch(uiActions.processCancelled('SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR'))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -174,6 +174,66 @@ export default function reducer(spotify = {}, action){
|
|||||||
}
|
}
|
||||||
return Object.assign({}, spotify, { library_albums: uris })
|
return Object.assign({}, spotify, { library_albums: uris })
|
||||||
|
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_PLAYLISTS_CLEAR':
|
||||||
|
return Object.assign({}, spotify, { library_playlists: [] })
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_ARTISTS_CLEAR':
|
||||||
|
return Object.assign({}, spotify, { library_artists: [] })
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_ALBUMS_CLEAR':
|
||||||
|
return Object.assign({}, spotify, { library_albums: [] })
|
||||||
|
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, spotify, { library_playlists_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_PLAYLISTS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, spotify, { library_playlists_status: 'finished' })
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, spotify, { library_artists_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_ARTISTS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, spotify, { library_artists_status: 'finished' })
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR_CANCELLED':
|
||||||
|
return Object.assign({}, spotify, { library_albums_status: 'cancelled' })
|
||||||
|
|
||||||
|
case 'SPOTIFY_GET_LIBRARY_ALBUMS_PROCESSOR_FINISHED':
|
||||||
|
return Object.assign({}, spotify, { library_albums_status: 'finished' })
|
||||||
|
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_ALBUM_CHECK':
|
||||||
|
var items = Object.assign([], spotify.library_albums)
|
||||||
|
var index = items.indexOf(action.key)
|
||||||
|
if (index > -1 && !action.in_library){
|
||||||
|
items.splice(index, 1)
|
||||||
|
} else if (index < 0 && action.in_library){
|
||||||
|
items.push(action.key)
|
||||||
|
}
|
||||||
|
return Object.assign({}, spotify, { library_albums: items });
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_ARTIST_CHECK':
|
||||||
|
var items = Object.assign([], spotify.library_artists)
|
||||||
|
var index = items.indexOf(action.key)
|
||||||
|
if (index > -1 && !action.in_library){
|
||||||
|
items.splice(index, 1)
|
||||||
|
} else if (index < 0 && action.in_library){
|
||||||
|
items.push(action.key)
|
||||||
|
}
|
||||||
|
return Object.assign({}, spotify, { library_artists: items });
|
||||||
|
|
||||||
|
case 'SPOTIFY_LIBRARY_PLAYLIST_CHECK':
|
||||||
|
var items = Object.assign([], spotify.library_playlists)
|
||||||
|
var index = items.indexOf(action.key)
|
||||||
|
if (index > -1 && !action.in_library){
|
||||||
|
items.splice(index, 1)
|
||||||
|
} else if (index < 0 && action.in_library){
|
||||||
|
items.push(action.key)
|
||||||
|
}
|
||||||
|
return Object.assign({}, spotify, { library_playlists: items });
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return spotify
|
return spotify
|
||||||
}
|
}
|
||||||
|
|||||||
@ -200,6 +200,13 @@ export function cancelProcess(key){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function processCancelled(key){
|
||||||
|
return {
|
||||||
|
type: 'PROCESS_CANCELLED',
|
||||||
|
key: key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function processFinished(key){
|
export function processFinished(key){
|
||||||
return {
|
return {
|
||||||
type: 'PROCESS_FINISHED',
|
type: 'PROCESS_FINISHED',
|
||||||
|
|||||||
@ -130,9 +130,16 @@ const UIMiddleware = (function(){
|
|||||||
next(action)
|
next(action)
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'CANCEL_PROCESS':
|
case 'PROCESS_CANCELLED':
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: action.key+'_CANCEL'
|
type: action.key+'_CANCELLED'
|
||||||
|
})
|
||||||
|
next(action)
|
||||||
|
break
|
||||||
|
|
||||||
|
case 'PROCESS_FINISHED':
|
||||||
|
store.dispatch({
|
||||||
|
type: action.key+'_FINISHED'
|
||||||
})
|
})
|
||||||
next(action)
|
next(action)
|
||||||
break
|
break
|
||||||
|
|||||||
@ -153,6 +153,7 @@ export default function reducer(ui = {}, action){
|
|||||||
}
|
}
|
||||||
return Object.assign({}, ui, {processes: processes})
|
return Object.assign({}, ui, {processes: processes})
|
||||||
|
|
||||||
|
case 'PROCESS_CANCELLED':
|
||||||
case 'PROCESS_FINISHED':
|
case 'PROCESS_FINISHED':
|
||||||
var processes = Object.assign({}, (ui.processes ? ui.processes : {}))
|
var processes = Object.assign({}, (ui.processes ? ui.processes : {}))
|
||||||
if (processes[action.key]){
|
if (processes[action.key]){
|
||||||
|
|||||||
@ -92,7 +92,8 @@ class Album extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
inLibrary(){
|
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(){
|
render(){
|
||||||
@ -172,7 +173,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
artists: state.core.artists,
|
artists: state.core.artists,
|
||||||
album: (state.core.albums && typeof(state.core.albums[ownProps.params.uri]) !== 'undefined' ? state.core.albums[ownProps.params.uri] : false ),
|
album: (state.core.albums && typeof(state.core.albums[ownProps.params.uri]) !== 'undefined' ? state.core.albums[ownProps.params.uri] : false ),
|
||||||
albums: state.core.albums,
|
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,
|
spotify_authorized: state.spotify.authorization,
|
||||||
mopidy_connected: state.mopidy.connected
|
mopidy_connected: state.mopidy.connected
|
||||||
};
|
};
|
||||||
|
|||||||
@ -82,7 +82,8 @@ class Artist extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
inLibrary(){
|
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(){
|
renderSubViewMenu(){
|
||||||
@ -263,7 +264,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
load_queue: state.ui.load_queue,
|
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 ),
|
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 : []),
|
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 : []),
|
albums: (state.core.albums ? state.core.albums : []),
|
||||||
spotify_authorized: state.spotify.authorization,
|
spotify_authorized: state.spotify.authorization,
|
||||||
mopidy_connected: state.mopidy.connected
|
mopidy_connected: state.mopidy.connected
|
||||||
|
|||||||
@ -105,7 +105,8 @@ class Playlist extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
inLibrary(){
|
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(){
|
renderActions(){
|
||||||
@ -115,7 +116,7 @@ class Playlist extends React.Component{
|
|||||||
return (
|
return (
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<button className="primary" onClick={ e => this.play() }>Play</button>
|
<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)} />}
|
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -125,7 +126,7 @@ class Playlist extends React.Component{
|
|||||||
return (
|
return (
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<button className="primary" onClick={ e => this.play() }>Play</button>
|
<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)} />}
|
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -133,7 +134,7 @@ class Playlist extends React.Component{
|
|||||||
return (
|
return (
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<button className="primary" onClick={ e => this.play() }>Play</button>
|
<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)} />}
|
{this.props.slim_mode ? null : <ContextMenuTrigger onTrigger={e => this.handleContextMenu(e)} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -214,8 +215,9 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
return {
|
return {
|
||||||
slim_mode: state.ui.slim_mode,
|
slim_mode: state.ui.slim_mode,
|
||||||
load_queue: state.ui.load_queue,
|
load_queue: state.ui.load_queue,
|
||||||
playlist: (state.core.playlists && typeof(state.core.playlists[uri]) !== 'undefined' ? state.core.playlists[uri] : false ),
|
playlist: (state.core.playlists && state.core.playlists[uri] !== undefined ? state.core.playlists[uri] : false ),
|
||||||
library_playlists: state.core.library_playlists,
|
spotify_library_playlists: state.spotify.library_playlists,
|
||||||
|
local_library_playlists: state.mopidy.library_playlists,
|
||||||
mopidy_connected: state.mopidy.connected,
|
mopidy_connected: state.mopidy.connected,
|
||||||
spotify_authorized: state.spotify.authorization,
|
spotify_authorized: state.spotify.authorization,
|
||||||
spotify_userid: state.spotify.me.id
|
spotify_userid: state.spotify.me.id
|
||||||
|
|||||||
@ -30,11 +30,11 @@ class LibraryAlbums extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(){
|
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()
|
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()
|
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
|
// 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()
|
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
|
// 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()
|
this.props.spotifyActions.getLibraryAlbums()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,8 +307,10 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
spotify_connected: state.spotify.connected,
|
spotify_connected: state.spotify.connected,
|
||||||
load_queue: state.ui.load_queue,
|
load_queue: state.ui.load_queue,
|
||||||
albums: state.core.albums,
|
albums: state.core.albums,
|
||||||
spotify_library_albums: state.spotify.library_albums,
|
|
||||||
mopidy_library_albums: state.mopidy.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,
|
view: state.ui.library_albums_view,
|
||||||
source: (state.ui.library_albums_source ? state.ui.library_albums_source : 'all'),
|
source: (state.ui.library_albums_source ? state.ui.library_albums_source : 'all'),
|
||||||
sort: (state.ui.library_albums_sort ? state.ui.library_albums_sort : 'name'),
|
sort: (state.ui.library_albums_sort ? state.ui.library_albums_sort : 'name'),
|
||||||
|
|||||||
@ -27,11 +27,11 @@ class LibraryArtists extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount(){
|
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()
|
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()
|
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
|
// 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()
|
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
|
// 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()
|
this.props.spotifyActions.getLibraryArtists()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,9 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
mopidy_connected: state.mopidy.connected,
|
mopidy_connected: state.mopidy.connected,
|
||||||
spotify_connected: state.spotify.connected,
|
spotify_connected: state.spotify.connected,
|
||||||
mopidy_library_artists: state.mopidy.library_artists,
|
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: state.spotify.library_artists,
|
||||||
|
spotify_library_artists_status: state.spotify.library_artists_status,
|
||||||
artists: state.core.artists,
|
artists: state.core.artists,
|
||||||
source: (state.ui.library_artists_source ? state.ui.library_artists_source : 'all'),
|
source: (state.ui.library_artists_source ? state.ui.library_artists_source : 'all'),
|
||||||
sort: (state.ui.library_artists_sort ? state.ui.library_artists_sort : 'name'),
|
sort: (state.ui.library_artists_sort ? state.ui.library_artists_sort : 'name'),
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class LibraryPlaylists extends React.Component{
|
|||||||
this.props.mopidyActions.getLibraryPlaylists()
|
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()
|
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
|
// 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()
|
this.props.spotifyActions.getLibraryPlaylists()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,7 +259,9 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
mopidy_connected: state.mopidy.connected,
|
mopidy_connected: state.mopidy.connected,
|
||||||
spotify_connected: state.spotify.connected,
|
spotify_connected: state.spotify.connected,
|
||||||
mopidy_library_playlists: state.mopidy.library_playlists,
|
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: state.spotify.library_playlists,
|
||||||
|
spotify_library_playlists_status: state.spotify.library_playlists_status,
|
||||||
slim_mode: state.ui.slim_mode,
|
slim_mode: state.ui.slim_mode,
|
||||||
load_queue: state.ui.load_queue,
|
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)),
|
me_id: (state.spotify.me ? state.spotify.me.id : (state.ui.config && state.ui.config.spotify_username ? state.ui.config.spotify_username : false)),
|
||||||
|
|||||||
Reference in New Issue
Block a user