Retaining search results by using URL params and keep results query

This commit is contained in:
James Barnsley
2019-06-10 13:49:57 +12:00
parent 4a303917ef
commit bd811ff007
11 changed files with 124 additions and 57 deletions

View File

@ -581,6 +581,7 @@ export function getSearchResults(type, query, limit = 50, offset = 0){
dispatch({
type: 'SPOTIFY_SEARCH_RESULTS_LOADED',
context: 'tracks',
query: query,
results: helpers.formatTracks(response.tracks.items),
more: response.tracks.next,
});
@ -594,6 +595,7 @@ export function getSearchResults(type, query, limit = 50, offset = 0){
dispatch({
type: 'SPOTIFY_SEARCH_RESULTS_LOADED',
context: 'artists',
query: query,
results: helpers.arrayOf('uri',response.artists.items),
more: response.artists.next,
});
@ -607,6 +609,7 @@ export function getSearchResults(type, query, limit = 50, offset = 0){
dispatch({
type: 'SPOTIFY_SEARCH_RESULTS_LOADED',
context: 'albums',
query: query,
results: helpers.arrayOf('uri',response.albums.items),
more: response.albums.next,
});
@ -632,6 +635,7 @@ export function getSearchResults(type, query, limit = 50, offset = 0){
dispatch({
type: 'SPOTIFY_SEARCH_RESULTS_LOADED',
context: 'playlists',
query: query,
results: helpers.arrayOf('uri',playlists),
more: response.playlists.next
});

View File

@ -334,6 +334,8 @@ export default function reducer(spotify = {}, action){
var search_results = {}
}
search_results.query = action.query;
if (search_results.results){
search_results[action.context] = [...search_results[action.context], ...action.results]
} else {