Checking on Link for null values; Playing already fully-loaded playlists

This commit is contained in:
James Barnsley
2019-03-29 14:20:06 +13:00
parent ccb0d6672a
commit 2a0cb74ca7
7 changed files with 5689 additions and 10844 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -98,7 +98,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1553131269";
var build = "1553731760";
var version = "3.33.0";
// Construct the script tag

View File

@ -64,7 +64,7 @@
"jest": {
"verbose": true,
"setupFilesAfterEnv": [
"./tests/setup.js"
"./tests/setup.js"
]
}
}

View File

@ -62,6 +62,10 @@ class CustomLink extends React.Component{
className += this.props.className;
}
if (!this.props.to){
return <span className={className}>{this.props.children}</span>;
}
// We have an active detector method
// This is used almost solely by the Sidebar navigation
if (this.props.history !== undefined){

View File

@ -596,15 +596,19 @@ const MopidyMiddleware = (function(){
**/
case 'MOPIDY_PLAY_PLAYLIST':
var playlist = store.getState().core.playlists[action.uri];
// We have the playlist loaded already, and we've got at least 1 track to start playing
if (playlist && playlist.tracks_uris && playlist.tracks_uris.length > 0){
// Spotify-provied playlists need to be handled by the Spotify service
// We only need to load them if we haven't already got all the tracks
if (playlist.provider == 'spotify' && playlist.tracks_total != playlist.tracks_uris.length){
// We've got all of the tracks, so just play those; no further action required
if (playlist.tracks_total == playlist.tracks_uris.length){
store.dispatch(mopidyActions.playURIs(playlist.tracks_uris, action.uri));
break;
}
// Spotify-provided playlists need to be handled by the Spotify service
if (playlist.provider == 'spotify'){
store.dispatch(spotifyActions.getAllPlaylistTracks(action.uri, action.shuffle, 'play'));
break;
}
@ -620,7 +624,7 @@ const MopidyMiddleware = (function(){
request(socket, store, 'playlists.lookup', {uri: action.uri})
.then(
response => {
if (response.tracks === undefined){
if (!response || response.tracks === undefined || !response.tracks){
store.dispatch(uiActions.createNotification({content: 'Failed to load playlist tracks', type: 'bad'}));
} else {
var tracks_uris = helpers.arrayOf('uri',response.tracks);

View File

@ -1671,8 +1671,10 @@ export function getAllPlaylistTracksProcessor(data){
// Add on our new batch of loaded tracks
var uris = []
var new_uris = []
for (var i = 0; i < response.items.length; i++){
new_uris.push(response.items[i].track.uri)
for (var item of response.items){
if (item.track){
new_uris.push(item.track.uri);
}
}
if (data.uris){
uris = [...data.uris, ...new_uris];