Discover moved to recommendations; URL handles context loading
This commit is contained in:
@ -498,14 +498,16 @@ export function getAutocompleteResults(field_id, query, types = ['album','artist
|
||||
.then(response => {
|
||||
var genres = []
|
||||
if (genre_included){
|
||||
var available_genres = getState().spotify.genres
|
||||
for (var i = 0; i < available_genres.length; i++){
|
||||
if (available_genres[i].includes(query)){
|
||||
var genre = available_genres[i]
|
||||
genres.push({
|
||||
name: (genre.charAt(0).toUpperCase()+genre.slice(1)).replace('-',' '),
|
||||
uri: 'spotify:genre:'+genre
|
||||
})
|
||||
var available_genres = getState().ui.genres
|
||||
if (available_genres){
|
||||
for (var i = 0; i < available_genres.length; i++){
|
||||
if (available_genres[i].includes(query)){
|
||||
var genre = available_genres[i]
|
||||
genres.push({
|
||||
name: (genre.charAt(0).toUpperCase()+genre.slice(1)).replace('-',' '),
|
||||
uri: 'spotify:genre:'+genre
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,6 +273,32 @@ const SpotifyMiddleware = (function(){
|
||||
});
|
||||
break
|
||||
|
||||
case 'SPOTIFY_FAVORITES_LOADED':
|
||||
if (action.artists.length > 0){
|
||||
store.dispatch({
|
||||
type: 'ARTISTS_LOADED',
|
||||
artists: action.artists
|
||||
})
|
||||
action.artists_uris = helpers.asURIs(action.artists)
|
||||
}
|
||||
if (action.tracks.length > 0){
|
||||
store.dispatch({
|
||||
type: 'TRACKS_LOADED',
|
||||
tracks: action.tracks
|
||||
})
|
||||
action.tracks_uris = helpers.asURIs(action.tracks)
|
||||
}
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'SPOTIFY_TRACK_LOADED':
|
||||
store.dispatch({
|
||||
type: 'TRACK_LOADED',
|
||||
key: action.data.uri,
|
||||
track: action.data
|
||||
});
|
||||
break
|
||||
|
||||
case 'SPOTIFY_SEARCH_RESULTS_LOADED_MORE_TRACKS':
|
||||
store.dispatch({
|
||||
type: 'SEARCH_RESULTS_LOADED',
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
|
||||
import * as helpers from '../../helpers'
|
||||
|
||||
export default function reducer(spotify = {}, action){
|
||||
switch (action.type) {
|
||||
|
||||
@ -179,9 +181,6 @@ export default function reducer(spotify = {}, action){
|
||||
if( !action.data ) return Object.assign({}, spotify, { discover: [] })
|
||||
return Object.assign({}, spotify, { discover: [...spotify.discover, ...[action.data]] })
|
||||
|
||||
case 'SPOTIFY_GENRES_LOADED':
|
||||
return Object.assign({}, spotify, {genres: action.genres})
|
||||
|
||||
case 'SPOTIFY_RECOMMENDATIONS_LOADED':
|
||||
return Object.assign(
|
||||
{},
|
||||
@ -199,8 +198,8 @@ export default function reducer(spotify = {}, action){
|
||||
{},
|
||||
spotify,
|
||||
{
|
||||
favorite_artists: action.artists,
|
||||
favorite_tracks: action.tracks
|
||||
favorite_artists: action.artists_uris,
|
||||
favorite_tracks: action.tracks_uris
|
||||
})
|
||||
|
||||
case 'SPOTIFY_AUTOCOMPLETE_LOADING':
|
||||
|
||||
Reference in New Issue
Block a user