Merge remote-tracking branch 'upstream/master' into win32
This commit is contained in:
5
src/js/bootstrap.js
vendored
5
src/js/bootstrap.js
vendored
@ -32,9 +32,10 @@ var initialState = {
|
||||
current_tracklist: [],
|
||||
current_tltrack: false,
|
||||
albums: {},
|
||||
users: {},
|
||||
artists: {},
|
||||
playlists: {},
|
||||
artists: {}
|
||||
users: {},
|
||||
tracks: {}
|
||||
},
|
||||
ui: {
|
||||
slim_mode: false,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
|
||||
var coreActions = require('../core/actions')
|
||||
var uiActions = require('../ui/actions')
|
||||
var helpers = require('../../helpers')
|
||||
|
||||
@ -10,25 +11,33 @@ var helpers = require('../../helpers')
|
||||
* @param endpoint params = the url params to send
|
||||
**/
|
||||
const sendRequest = ( dispatch, getState, params ) => {
|
||||
return new Promise( (resolve, reject) => {
|
||||
|
||||
var url = '//ws.audioscrobbler.com/2.0/?format=json&api_key=4320a3ef51c9b3d69de552ac083c55e3&'+params
|
||||
return new Promise( (resolve, reject) => {
|
||||
|
||||
var loader_key = helpers.generateGuid()
|
||||
dispatch(uiActions.startLoading(loader_key, 'lastfm_'+params))
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
cache: true,
|
||||
url: url
|
||||
}).then(
|
||||
var config = {
|
||||
method: 'GET',
|
||||
cache: true,
|
||||
url: '//ws.audioscrobbler.com/2.0/?format=json&api_key=4320a3ef51c9b3d69de552ac083c55e3&'+params
|
||||
}
|
||||
|
||||
$.ajax(config).then(
|
||||
response => {
|
||||
dispatch(uiActions.stopLoading(loader_key))
|
||||
resolve(response)
|
||||
},
|
||||
(xhr, status, error) => {
|
||||
dispatch(uiActions.stopLoading(loader_key))
|
||||
console.error( params+' failed', xhr.responseText)
|
||||
dispatch(coreActions.handleException(
|
||||
'LastFM: '+xhr.responseText,
|
||||
{
|
||||
config: config,
|
||||
error: error,
|
||||
status: status,
|
||||
xhr: xhr
|
||||
}
|
||||
));
|
||||
reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
@ -146,7 +146,7 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
|
||||
store.dispatch(coreActions.handleException(
|
||||
error.message,
|
||||
'Mopidy: '+error.message,
|
||||
error
|
||||
));
|
||||
|
||||
@ -331,7 +331,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Lookup failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Lookup failed"),
|
||||
error
|
||||
));
|
||||
}
|
||||
);
|
||||
break;
|
||||
@ -455,7 +458,10 @@ const MopidyMiddleware = (function(){
|
||||
)
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Adding tracks failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Adding tracks failed"),
|
||||
error
|
||||
));
|
||||
}
|
||||
)
|
||||
|
||||
@ -489,7 +495,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
store.dispatch(pusherActions.addQueueMetadata(tlids, action.from_uri))
|
||||
} else {
|
||||
store.dispatch(coreActions.handleException("Failed to add some tracks",response));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: Failed to add some tracks",
|
||||
response
|
||||
));
|
||||
}
|
||||
|
||||
// add the rest of our uris (if any)
|
||||
@ -507,7 +516,10 @@ const MopidyMiddleware = (function(){
|
||||
}
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Adding tracks failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Adding tracks failed"),
|
||||
error
|
||||
));
|
||||
}
|
||||
)
|
||||
break;
|
||||
@ -521,7 +533,10 @@ const MopidyMiddleware = (function(){
|
||||
// TODO: when complete, send event to confirm success/failure
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Reorder failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Reorder failed"),
|
||||
error
|
||||
));
|
||||
}
|
||||
)
|
||||
break;
|
||||
@ -649,7 +664,10 @@ const MopidyMiddleware = (function(){
|
||||
continue_process();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
continue_process();
|
||||
}
|
||||
)
|
||||
@ -713,7 +731,10 @@ const MopidyMiddleware = (function(){
|
||||
continue_process();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
continue_process();
|
||||
}
|
||||
);
|
||||
@ -761,7 +782,10 @@ const MopidyMiddleware = (function(){
|
||||
continue_process();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
continue_process();
|
||||
}
|
||||
)
|
||||
@ -803,7 +827,10 @@ const MopidyMiddleware = (function(){
|
||||
continue_process();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
continue_process();
|
||||
}
|
||||
)
|
||||
@ -836,7 +863,10 @@ const MopidyMiddleware = (function(){
|
||||
process_albums();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
process_albums();
|
||||
}
|
||||
);
|
||||
@ -884,7 +914,10 @@ const MopidyMiddleware = (function(){
|
||||
process_artists();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
process_artists();
|
||||
}
|
||||
);
|
||||
@ -935,7 +968,10 @@ const MopidyMiddleware = (function(){
|
||||
process_playlists();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
process_playlists();
|
||||
}
|
||||
);
|
||||
@ -996,7 +1032,10 @@ const MopidyMiddleware = (function(){
|
||||
finished();
|
||||
},
|
||||
error => {
|
||||
store.dispatch(coreActions.handleException((error.message ? error.message : "Search failed"),error));
|
||||
store.dispatch(coreActions.handleException(
|
||||
"Mopidy: "+(error.message ? error.message : "Search failed"),
|
||||
error
|
||||
));
|
||||
finished();
|
||||
}
|
||||
);
|
||||
|
||||
@ -24,7 +24,7 @@ const PusherMiddleware = (function(){
|
||||
// error
|
||||
if (message.status == 0){
|
||||
store.dispatch(coreActions.handleException(
|
||||
message.message,
|
||||
'Pusher: '+message.message,
|
||||
message
|
||||
));
|
||||
}
|
||||
@ -37,7 +37,7 @@ const PusherMiddleware = (function(){
|
||||
|
||||
} else {
|
||||
store.dispatch(coreActions.handleException(
|
||||
'Pusher response received with no matching request',
|
||||
'Pusher: Response received with no matching request',
|
||||
message
|
||||
));
|
||||
}
|
||||
|
||||
@ -56,8 +56,9 @@ const sendRequest = ( dispatch, getState, endpoint, method = 'GET', data = false
|
||||
(xhr, status, error) => {
|
||||
dispatch(uiActions.stopLoading(loader_key))
|
||||
dispatch(coreActions.handleException(
|
||||
xhr.responseJSON.error.message,
|
||||
'Spotify: '+xhr.responseJSON.error.message,
|
||||
{
|
||||
source: 'spotify/actions.js/sendRequest',
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
status: status,
|
||||
@ -99,10 +100,6 @@ function getToken( dispatch, getState ){
|
||||
.then(
|
||||
response => {
|
||||
resolve(response.access_token)
|
||||
},
|
||||
error => {
|
||||
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
|
||||
reject(error)
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -134,8 +131,9 @@ function refreshToken( dispatch, getState ){
|
||||
(xhr, status, error) => {
|
||||
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
|
||||
dispatch(coreActions.handleException(
|
||||
xhr.responseJSON.error_description,
|
||||
'Spotify: '+xhr.responseJSON.error_description,
|
||||
{
|
||||
source: 'spotify/actions.js/refreshToken',
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
status: status,
|
||||
@ -146,7 +144,7 @@ function refreshToken( dispatch, getState ){
|
||||
}
|
||||
);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
@ -158,8 +156,16 @@ function refreshToken( dispatch, getState ){
|
||||
response => {
|
||||
if (response.type == 'error'){
|
||||
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
|
||||
dispatch(uiActions.createNotification(response.message,'bad'))
|
||||
console.error('Could not refresh token', response)
|
||||
dispatch(coreActions.handleException(
|
||||
'Spotify: '+response.message,
|
||||
{
|
||||
source: 'spotify/actions.js/refreshToken',
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
status: status,
|
||||
error: error
|
||||
}
|
||||
))
|
||||
reject(response)
|
||||
|
||||
} else {
|
||||
@ -177,8 +183,16 @@ function refreshToken( dispatch, getState ){
|
||||
},
|
||||
error => {
|
||||
dispatch({ type: 'SPOTIFY_DISCONNECTED' })
|
||||
dispatch(uiActions.createNotification('Could not refresh token','bad'))
|
||||
console.error('Could not refresh token', error)
|
||||
dispatch(coreActions.handleException(
|
||||
'Spotify: Could not refresh token',
|
||||
{
|
||||
source: 'spotify/actions.js/refreshToken',
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
status: status,
|
||||
error: error
|
||||
}
|
||||
))
|
||||
reject(error)
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user