Retaining search results by using URL params and keep results query
This commit is contained in:
@ -1020,7 +1020,7 @@ const MopidyMiddleware = (function(){
|
||||
{
|
||||
remaining: action.data.uri_schemes.length
|
||||
}
|
||||
))
|
||||
));
|
||||
|
||||
switch (action.data.context){
|
||||
|
||||
@ -1080,6 +1080,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: action.data.context,
|
||||
results: albums_uris
|
||||
})
|
||||
@ -1162,6 +1163,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: action.data.context,
|
||||
results: artists_uris
|
||||
})
|
||||
@ -1219,6 +1221,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: action.data.context,
|
||||
results: playlists_uris
|
||||
})
|
||||
@ -1271,6 +1274,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: action.data.context,
|
||||
results: helpers.formatTracks(tracks)
|
||||
});
|
||||
@ -1316,6 +1320,7 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: 'tracks',
|
||||
results: helpers.formatTracks(tracks)
|
||||
});
|
||||
@ -1377,6 +1382,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: 'albums',
|
||||
results: albums_uris
|
||||
})
|
||||
@ -1447,6 +1453,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: 'artists',
|
||||
results: artists_uris
|
||||
})
|
||||
@ -1503,6 +1510,7 @@ const MopidyMiddleware = (function(){
|
||||
// and plug in their URIs
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||
query: action.data.query,
|
||||
context: 'playlists',
|
||||
results: playlists_uris
|
||||
})
|
||||
|
||||
@ -193,15 +193,17 @@ export default function reducer(mopidy = {}, action){
|
||||
|
||||
// Fetch or create our container
|
||||
if (mopidy.search_results){
|
||||
var search_results = Object.assign({}, mopidy.search_results)
|
||||
var search_results = Object.assign({}, mopidy.search_results);
|
||||
} else {
|
||||
var search_results = {}
|
||||
var search_results = {};
|
||||
}
|
||||
|
||||
search_results.query = action.query;
|
||||
|
||||
if (search_results[action.context]){
|
||||
search_results[action.context] = [...search_results[action.context], ...action.results]
|
||||
search_results[action.context] = [...search_results[action.context], ...action.results];
|
||||
} else {
|
||||
search_results[action.context] = action.results
|
||||
search_results[action.context] = action.results;
|
||||
}
|
||||
|
||||
return Object.assign({}, mopidy, { search_results: search_results });
|
||||
|
||||
@ -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
|
||||
});
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user