Ignore duplicate albums; Don't search when no seeds
This commit is contained in:
@ -718,10 +718,17 @@ export function getRecommendations(uris = [], limit = 20){
|
||||
|
||||
// Copy already loaded albums into array
|
||||
var albums = []
|
||||
var albums_uris = []
|
||||
if (response.tracks.length > 10){
|
||||
for (var i = 0; i < 5; i++){
|
||||
while (albums.length < 5){
|
||||
var random_index = Math.round(Math.random() * (response.tracks.length - 1))
|
||||
albums.push(response.tracks[random_index].album)
|
||||
var album = response.tracks[random_index].album
|
||||
|
||||
// Make sure this album is not already in our sample
|
||||
if (!albums_uris.includes(album.uri)){
|
||||
albums_uris.push(album.uri)
|
||||
albums.push(album)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,10 +30,7 @@ class Discover extends React.Component{
|
||||
}
|
||||
],
|
||||
add_seed: '',
|
||||
adding_seed: false,
|
||||
artists: [],
|
||||
albums: [],
|
||||
tracks: []
|
||||
adding_seed: false
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +57,7 @@ class Discover extends React.Component{
|
||||
}
|
||||
|
||||
getRecommendations(seeds = this.state.seeds){
|
||||
if (seeds){
|
||||
if (seeds.length > 0){
|
||||
var uris = helpers.asURIs(seeds)
|
||||
this.props.spotifyActions.getRecommendations(uris, 50)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user