Respecting cancelling searches
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
// Release details
|
// Release details
|
||||||
// These are automatically injected to built HTML
|
// These are automatically injected to built HTML
|
||||||
var build = "1534105233";
|
var build = "1534236383";
|
||||||
var version = "3.23.2";
|
var version = "3.23.2";
|
||||||
|
|
||||||
// Construct the script tag
|
// Construct the script tag
|
||||||
|
|||||||
@ -865,11 +865,11 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
|
|
||||||
case 'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR':
|
case 'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR':
|
||||||
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
|
||||||
// Cancelling
|
// Cancelling
|
||||||
if (last_run && last_run.status == 'cancelling'){
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'))
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
return
|
return
|
||||||
|
|
||||||
// No more schemes, so we're done!
|
// No more schemes, so we're done!
|
||||||
@ -895,6 +895,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
// Albums
|
// Albums
|
||||||
case 'albums':
|
case 'albums':
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
@ -964,6 +971,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
// Artists
|
// Artists
|
||||||
case 'artists':
|
case 'artists':
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
@ -1039,6 +1053,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
// Playlists
|
// Playlists
|
||||||
case 'playlists':
|
case 'playlists':
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
@ -1088,6 +1109,13 @@ const MopidyMiddleware = (function(){
|
|||||||
|
|
||||||
// Tracks
|
// Tracks
|
||||||
case 'tracks':
|
case 'tracks':
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
@ -1135,38 +1163,57 @@ const MopidyMiddleware = (function(){
|
|||||||
// Search for all types
|
// Search for all types
|
||||||
case 'all':
|
case 'all':
|
||||||
default:
|
default:
|
||||||
store.dispatch(uiActions.updateProcess(
|
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
var process_tracks = () => {
|
||||||
'Searching '+action.data.uri_scheme.replace(':','')+' tracks',
|
|
||||||
{
|
// Quick check to see if we should be cancelling
|
||||||
remaining: (action.data.uri_schemes.length) + 1
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
));
|
|
||||||
request(socket, store, 'library.search', {query: {any: [action.data.query]}, uris: [action.data.uri_scheme]})
|
|
||||||
.then(
|
|
||||||
response => {
|
|
||||||
if (response.length > 0 && response[0].tracks !== undefined){
|
|
||||||
var tracks = response[0].tracks;
|
|
||||||
|
|
||||||
store.dispatch({
|
store.dispatch(uiActions.updateProcess(
|
||||||
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
context: 'tracks',
|
'Searching '+action.data.uri_scheme.replace(':','')+' tracks',
|
||||||
results: helpers.formatTracks(tracks)
|
{
|
||||||
});
|
remaining: (action.data.uri_schemes.length) + 1
|
||||||
}
|
|
||||||
|
|
||||||
process_albums();
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
store.dispatch(coreActions.handleException(
|
|
||||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
|
||||||
error
|
|
||||||
));
|
|
||||||
process_albums();
|
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
request(socket, store, 'library.search', {query: {any: [action.data.query]}, uris: [action.data.uri_scheme]})
|
||||||
|
.then(
|
||||||
|
response => {
|
||||||
|
if (response.length > 0 && response[0].tracks !== undefined){
|
||||||
|
var tracks = response[0].tracks;
|
||||||
|
|
||||||
|
store.dispatch({
|
||||||
|
type: 'MOPIDY_SEARCH_RESULTS_LOADED',
|
||||||
|
context: 'tracks',
|
||||||
|
results: helpers.formatTracks(tracks)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
process_albums();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
store.dispatch(coreActions.handleException(
|
||||||
|
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||||
|
error
|
||||||
|
));
|
||||||
|
process_albums();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
var process_albums = () => {
|
var process_albums = () => {
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
'Searching '+action.data.uri_scheme.replace(':','')+' albums',
|
'Searching '+action.data.uri_scheme.replace(':','')+' albums',
|
||||||
@ -1223,6 +1270,14 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
var process_artists = () => {
|
var process_artists = () => {
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
'Searching '+action.data.uri_scheme.replace(':','')+' artists',
|
'Searching '+action.data.uri_scheme.replace(':','')+' artists',
|
||||||
@ -1283,23 +1338,15 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var finished = () => {
|
|
||||||
// We're finally done searching for types on this provider
|
|
||||||
// On to the next scheme!
|
|
||||||
store.dispatch(uiActions.runProcess(
|
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
|
||||||
{
|
|
||||||
context: action.data.context,
|
|
||||||
query: action.data.query,
|
|
||||||
limit: action.data.limit,
|
|
||||||
uri_scheme: next_uri_scheme,
|
|
||||||
uri_schemes: next_uri_schemes,
|
|
||||||
remaining: action.data.uri_schemes.length
|
|
||||||
}
|
|
||||||
))
|
|
||||||
}
|
|
||||||
var process_playlists = () => {
|
var process_playlists = () => {
|
||||||
|
|
||||||
|
// Quick check to see if we should be cancelling
|
||||||
|
var last_run = store.getState().ui.processes.MOPIDY_GET_SEARCH_RESULTS_PROCESSOR;
|
||||||
|
if (last_run && last_run.status == 'cancelling'){
|
||||||
|
store.dispatch(uiActions.processCancelled('MOPIDY_GET_SEARCH_RESULTS_PROCESSOR'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (action.data.uri_scheme == 'm3u:'){
|
if (action.data.uri_scheme == 'm3u:'){
|
||||||
store.dispatch(uiActions.updateProcess(
|
store.dispatch(uiActions.updateProcess(
|
||||||
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
@ -1350,6 +1397,25 @@ const MopidyMiddleware = (function(){
|
|||||||
finished();
|
finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var finished = () => {
|
||||||
|
// We're finally done searching for types on this provider
|
||||||
|
// On to the next scheme!
|
||||||
|
store.dispatch(uiActions.runProcess(
|
||||||
|
'MOPIDY_GET_SEARCH_RESULTS_PROCESSOR',
|
||||||
|
{
|
||||||
|
context: action.data.context,
|
||||||
|
query: action.data.query,
|
||||||
|
limit: action.data.limit,
|
||||||
|
uri_scheme: next_uri_scheme,
|
||||||
|
uri_schemes: next_uri_schemes,
|
||||||
|
remaining: action.data.uri_schemes.length
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick things off with the tracks
|
||||||
|
process_tracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user