Fixing add/remove track from library

This commit is contained in:
James Barnsley
2019-09-26 10:22:43 +12:00
parent f7808f954a
commit e17bf47fc5
7 changed files with 18 additions and 32 deletions

View File

@ -632,6 +632,8 @@ class IrisCore(pykka.ThreadingActor):
if (not added.get()):
logger.error("No recommendations added to queue")
print added.get()
self.radio['enabled'] = 0;
error = {
'message': 'No recommendations added to queue',

View File

@ -78939,28 +78939,19 @@ var request = function request(dispatch, getState, endpoint) {
dispatch(uiActions.stopLoading(loader_key));
// TODO: Rate limiting
if (response.status == 429) {
alert('You hit the Spotify API rate limiter');
if (response.status === 429) {
console.error('You hit the Spotify API rate limiter');
}
// Empty Response
if (response.status == 204) {
return Promise.resolve();
// Otherwise successful
} else if (response.status >= 200 && response.status < 400) {
return Promise.resolve(response.json());
// Not so successful
} else {
return Promise.reject(new Error(response.statusText));
}
return response.text().then(function (text) {
return text ? JSON.parse(text) : {};
});
}
fetch(url, config).then(status).then(function (data) {
// TODO: Instead of allowing request to fail before renewing the token, once refreshed
// we should retry the original request(s)
if (data && data.error && data.error.message == 'The access token expired') {
if (data && data.error && data.error.message === 'The access token expired') {
dispatch(refreshToken(dispatch, getState));
}

File diff suppressed because one or more lines are too long

View File

@ -100,7 +100,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1569276474";
var build = "1569443683";
var version = "3.40.0";
// Construct the script tag

View File

@ -3,6 +3,8 @@ const blacklist = [
'jamesbarnsley.co.nz',
'following/contains',
'followers/contains',
'me/tracks',
'me/albums',
'refresh_spotify_token'
];
function inBlacklist(url) {

View File

@ -57,22 +57,11 @@ const request = (dispatch, getState, endpoint, method = 'GET', data = false, cac
dispatch(uiActions.stopLoading(loader_key));
// TODO: Rate limiting
if (response.status == 429) {
alert('You hit the Spotify API rate limiter');
if (response.status === 429) {
console.error('You hit the Spotify API rate limiter');
}
// Empty Response
if (response.status == 204) {
return Promise.resolve();
// Otherwise successful
} else if (response.status >= 200 && response.status < 400) {
return Promise.resolve(response.json());
// Not so successful
} else {
return Promise.reject(new Error(response.statusText))
}
return response.text().then((text) => (text ? JSON.parse(text) : {}));
}
fetch(url, config)
@ -80,7 +69,7 @@ const request = (dispatch, getState, endpoint, method = 'GET', data = false, cac
.then(data => {
// TODO: Instead of allowing request to fail before renewing the token, once refreshed
// we should retry the original request(s)
if (data && data.error && data.error.message == 'The access token expired') {
if (data && data.error && data.error.message === 'The access token expired') {
dispatch(refreshToken(dispatch, getState));
}

View File

@ -3,6 +3,8 @@ const blacklist = [
'jamesbarnsley.co.nz',
'following/contains',
'followers/contains',
'me/tracks',
'me/albums',
'refresh_spotify_token'
];
function inBlacklist(url) {