Refresh token into loader queue
This commit is contained in:
@ -3240,7 +3240,7 @@ var helpers = __webpack_require__(1);
|
||||
* @param data mixed = request payload
|
||||
* @return Promise
|
||||
**/
|
||||
var sendRequest = function sendRequest(dispatch, getState, endpoint) {
|
||||
var request = function request(dispatch, getState, endpoint) {
|
||||
var method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'GET';
|
||||
var data = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
||||
|
||||
@ -3334,6 +3334,11 @@ function getToken(dispatch, getState) {
|
||||
function refreshToken(dispatch, getState) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
// add reference to loader queue
|
||||
var loader_key = helpers.generateGuid();
|
||||
dispatch(uiActions.startLoading(loader_key, 'spotify_refresh_token'));
|
||||
|
||||
// Fully-authorized, so we can use the local Spotify credentials
|
||||
if (getState().spotify.authorization) {
|
||||
|
||||
var config = {
|
||||
@ -3344,6 +3349,8 @@ function refreshToken(dispatch, getState) {
|
||||
};
|
||||
|
||||
$.ajax(config).then(function (response) {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
response.token_expiry = new Date().getTime() + response.expires_in * 1000;
|
||||
response.source = 'spotify';
|
||||
dispatch({
|
||||
@ -3352,6 +3359,8 @@ function refreshToken(dispatch, getState) {
|
||||
});
|
||||
resolve(response);
|
||||
}, function (xhr, status, error) {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
reject({
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
@ -3359,6 +3368,9 @@ function refreshToken(dispatch, getState) {
|
||||
error: error
|
||||
});
|
||||
});
|
||||
|
||||
// Server-side authorized (with limited scope) so we need to refresh
|
||||
// using the Mopidy-Spotify credentials
|
||||
} else {
|
||||
|
||||
var config = {
|
||||
@ -3369,6 +3381,8 @@ function refreshToken(dispatch, getState) {
|
||||
};
|
||||
|
||||
$.ajax(config).then(function (response, status, xhr) {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
if (response.error) {
|
||||
reject({
|
||||
config: config,
|
||||
@ -3388,6 +3402,8 @@ function refreshToken(dispatch, getState) {
|
||||
resolve(token);
|
||||
}
|
||||
}, function (xhr, status, error) {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
reject({
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
@ -3452,7 +3468,7 @@ function importAuthorization(authorization) {
|
||||
**/
|
||||
function getMe() {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'me').then(function (response) {
|
||||
request(dispatch, getState, 'me').then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ME_LOADED',
|
||||
me: response
|
||||
@ -3470,7 +3486,7 @@ function getMe() {
|
||||
**/
|
||||
function getTrack(uri) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'tracks/' + helpers.getFromUri('trackid', uri)).then(function (response) {
|
||||
request(dispatch, getState, 'tracks/' + helpers.getFromUri('trackid', uri)).then(function (response) {
|
||||
dispatch(coreActions.trackLoaded(response));
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load track', error));
|
||||
@ -3480,7 +3496,7 @@ function getTrack(uri) {
|
||||
|
||||
function getLibraryTracks() {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'me/tracks?limit=50').then(function (response) {
|
||||
request(dispatch, getState, 'me/tracks?limit=50').then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_LIBRARY_TRACKS_LOADED',
|
||||
data: response
|
||||
@ -3512,7 +3528,7 @@ function getFeaturedPlaylists() {
|
||||
|
||||
var timestamp = year + '-' + month + '-' + day + 'T' + hour + ':' + min + ':' + sec;
|
||||
|
||||
sendRequest(dispatch, getState, 'browse/featured-playlists?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale + 'timestamp=' + timestamp).then(function (response) {
|
||||
request(dispatch, getState, 'browse/featured-playlists?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale + 'timestamp=' + timestamp).then(function (response) {
|
||||
var playlists = [];
|
||||
for (var i = 0; i < response.playlists.items.length; i++) {
|
||||
playlists.push(Object.assign({}, response.playlists.items[i], {
|
||||
@ -3546,7 +3562,7 @@ function getFeaturedPlaylists() {
|
||||
|
||||
function getCategories() {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'browse/categories?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
request(dispatch, getState, 'browse/categories?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_CATEGORIES_LOADED',
|
||||
categories: response.categories.items
|
||||
@ -3559,7 +3575,7 @@ function getCategories() {
|
||||
|
||||
function getCategory(id) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'browse/categories/' + id + '?country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
request(dispatch, getState, 'browse/categories/' + id + '?country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_CATEGORY_LOADED',
|
||||
category: Object.assign({
|
||||
@ -3575,7 +3591,7 @@ function getCategory(id) {
|
||||
|
||||
function getCategoryPlaylists(id) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'browse/categories/' + id + '/playlists?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
request(dispatch, getState, 'browse/categories/' + id + '/playlists?limit=50&country=' + getState().spotify.country + '&locale=' + getState().spotify.locale).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_CATEGORY_PLAYLISTS_LOADED',
|
||||
uri: 'category:' + id,
|
||||
@ -3589,7 +3605,7 @@ function getCategoryPlaylists(id) {
|
||||
|
||||
function getNewReleases() {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'browse/new-releases?country=' + getState().spotify.country + '&limit=50').then(function (response) {
|
||||
request(dispatch, getState, 'browse/new-releases?country=' + getState().spotify.country + '&limit=50').then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_NEW_RELEASES_LOADED',
|
||||
data: response
|
||||
@ -3604,7 +3620,7 @@ function getURL(url, action_name) {
|
||||
var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, url).then(function (response) {
|
||||
request(dispatch, getState, url).then(function (response) {
|
||||
dispatch({
|
||||
type: action_name,
|
||||
key: key,
|
||||
@ -3621,7 +3637,7 @@ function getMore(url) {
|
||||
var custom_action = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
||||
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, url).then(function (response) {
|
||||
request(dispatch, getState, url).then(function (response) {
|
||||
if (core_action) {
|
||||
dispatch(coreActions.loadedMore(core_action.parent_type, core_action.parent_key, core_action.records_type, response));
|
||||
} else if (custom_action) {
|
||||
@ -3661,7 +3677,7 @@ function getSearchResults(type, query) {
|
||||
url += '&limit=' + limit;
|
||||
url += '&offset=' + offset;
|
||||
|
||||
sendRequest(dispatch, getState, url).then(function (response) {
|
||||
request(dispatch, getState, url).then(function (response) {
|
||||
if (response.tracks !== undefined) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_SEARCH_RESULTS_LOADED',
|
||||
@ -3764,7 +3780,7 @@ function getAutocompleteResults(field_id, query) {
|
||||
endpoint += '&type=' + types.join(',');
|
||||
endpoint += '&country=' + getState().spotify.country;
|
||||
|
||||
sendRequest(dispatch, getState, endpoint).then(function (response) {
|
||||
request(dispatch, getState, endpoint).then(function (response) {
|
||||
var genres = [];
|
||||
if (genre_included) {
|
||||
var available_genres = getState().spotify.genres;
|
||||
@ -3873,7 +3889,7 @@ function following(uri) {
|
||||
break;
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, endpoint, method, data).then(function (response) {
|
||||
request(dispatch, getState, endpoint, method, data).then(function (response) {
|
||||
if (response) is_following = response;
|
||||
if ((typeof is_following === 'undefined' ? 'undefined' : _typeof(is_following)) === 'object') is_following = is_following[0];
|
||||
|
||||
@ -3903,7 +3919,7 @@ function resolveRadioSeeds(radio) {
|
||||
artist_ids += helpers.getFromUri('artistid', radio.seed_artists[i]);
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'artists?ids=' + artist_ids).then(function (response) {
|
||||
request(dispatch, getState, 'artists?ids=' + artist_ids).then(function (response) {
|
||||
if (response && response.artists) {
|
||||
dispatch({
|
||||
type: 'ARTISTS_LOADED',
|
||||
@ -3924,7 +3940,7 @@ function resolveRadioSeeds(radio) {
|
||||
track_ids += helpers.getFromUri('trackid', radio.seed_tracks[i]);
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'tracks?ids=' + track_ids).then(function (response) {
|
||||
request(dispatch, getState, 'tracks?ids=' + track_ids).then(function (response) {
|
||||
dispatch({
|
||||
type: 'TRACKS_LOADED',
|
||||
tracks: response.tracks
|
||||
@ -3954,7 +3970,7 @@ function getFavorites() {
|
||||
|
||||
dispatch({ type: 'SPOTIFY_FAVORITES_LOADED', artists: [], tracks: [] });
|
||||
|
||||
$.when(sendRequest(dispatch, getState, 'me/top/artists?limit=' + limit + '&time_range=' + term), sendRequest(dispatch, getState, 'me/top/tracks?limit=' + limit + '&time_range=' + term)).then(function (artists_response, tracks_response) {
|
||||
$.when(request(dispatch, getState, 'me/top/artists?limit=' + limit + '&time_range=' + term), request(dispatch, getState, 'me/top/tracks?limit=' + limit + '&time_range=' + term)).then(function (artists_response, tracks_response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_FAVORITES_LOADED',
|
||||
artists: artists_response.items,
|
||||
@ -4024,7 +4040,7 @@ function getRecommendations() {
|
||||
}
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, endpoint).then(function (response) {
|
||||
request(dispatch, getState, endpoint).then(function (response) {
|
||||
var tracks = Object.assign([], response.tracks);
|
||||
|
||||
// We only get simple artist objects, so we need to
|
||||
@ -4089,7 +4105,7 @@ function getRecommendations() {
|
||||
**/
|
||||
function getGenres() {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'recommendations/available-genre-seeds').then(function (response) {
|
||||
request(dispatch, getState, 'recommendations/available-genre-seeds').then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_GENRES_LOADED',
|
||||
genres: response.genres
|
||||
@ -4121,7 +4137,7 @@ function getArtist(uri) {
|
||||
var artist = {};
|
||||
|
||||
// We need our artist, obviously
|
||||
var requests = [sendRequest(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri)).then(function (response) {
|
||||
var requests = [request(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri)).then(function (response) {
|
||||
Object.assign(artist, response);
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load artist', error));
|
||||
@ -4130,13 +4146,13 @@ function getArtist(uri) {
|
||||
// Do we want a full artist, with all supporting material?
|
||||
if (full) {
|
||||
|
||||
requests.push(sendRequest(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/top-tracks?country=' + getState().spotify.country).then(function (response) {
|
||||
requests.push(request(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/top-tracks?country=' + getState().spotify.country).then(function (response) {
|
||||
Object.assign(artist, response);
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load artist\'s top tracks', error));
|
||||
}));
|
||||
|
||||
requests.push(sendRequest(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/related-artists').then(function (response) {
|
||||
requests.push(request(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/related-artists').then(function (response) {
|
||||
dispatch(coreActions.artistsLoaded(response.artists));
|
||||
Object.assign(artist, { related_artists_uris: helpers.arrayOf('uri', response.artists) });
|
||||
}, function (error) {
|
||||
@ -4157,7 +4173,7 @@ function getArtist(uri) {
|
||||
|
||||
// Now go get our artist albums
|
||||
if (full) {
|
||||
sendRequest(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/albums?market=' + getState().spotify.country).then(function (response) {
|
||||
request(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/albums?market=' + getState().spotify.country).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ARTIST_ALBUMS_LOADED',
|
||||
artist_uri: uri,
|
||||
@ -4181,7 +4197,7 @@ function getArtists(uris) {
|
||||
ids += helpers.getFromUri('artistid', uris[i]);
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'artists/?ids=' + ids).then(function (response) {
|
||||
request(dispatch, getState, 'artists/?ids=' + ids).then(function (response) {
|
||||
for (var i = i; i < response.length; i++) {
|
||||
var artist = response;
|
||||
for (var i = 0; i < artist.albums.length; i++) {
|
||||
@ -4211,7 +4227,7 @@ function playArtistTopTracks(uri) {
|
||||
|
||||
// We need to load the artist's top tracks first
|
||||
} else {
|
||||
sendRequest(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/top-tracks?country=' + getState().spotify.country).then(function (response) {
|
||||
request(dispatch, getState, 'artists/' + helpers.getFromUri('artistid', uri) + '/top-tracks?country=' + getState().spotify.country).then(function (response) {
|
||||
var uris = helpers.arrayOf('uri', response.tracks);
|
||||
dispatch(mopidyActions.playURIs(uris, uri));
|
||||
}, function (error) {
|
||||
@ -4228,7 +4244,7 @@ function playArtistTopTracks(uri) {
|
||||
|
||||
function getUser(uri) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'users/' + helpers.getFromUri('userid', uri)).then(function (response) {
|
||||
request(dispatch, getState, 'users/' + helpers.getFromUri('userid', uri)).then(function (response) {
|
||||
dispatch(coreActions.userLoaded(helpers.formatUser(response)));
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load user', error));
|
||||
@ -4240,7 +4256,7 @@ function getUserPlaylists(uri) {
|
||||
return function (dispatch, getState) {
|
||||
|
||||
// get the first page of playlists
|
||||
sendRequest(dispatch, getState, 'users/' + helpers.getFromUri('userid', uri) + '/playlists?limit=40').then(function (response) {
|
||||
request(dispatch, getState, 'users/' + helpers.getFromUri('userid', uri) + '/playlists?limit=40').then(function (response) {
|
||||
var playlists = [];
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
@ -4299,7 +4315,7 @@ function getAlbum(uri) {
|
||||
return function (dispatch, getState) {
|
||||
|
||||
// get the album
|
||||
sendRequest(dispatch, getState, 'albums/' + helpers.getFromUri('albumid', uri)).then(function (response) {
|
||||
request(dispatch, getState, 'albums/' + helpers.getFromUri('albumid', uri)).then(function (response) {
|
||||
|
||||
// dispatch our loaded artists (simple objects)
|
||||
dispatch(coreActions.artistsLoaded(response.artists));
|
||||
@ -4332,7 +4348,7 @@ function getAlbum(uri) {
|
||||
}
|
||||
|
||||
// get all album artists as full objects
|
||||
sendRequest(dispatch, getState, 'artists/?ids=' + artist_ids).then(function (response) {
|
||||
request(dispatch, getState, 'artists/?ids=' + artist_ids).then(function (response) {
|
||||
dispatch(coreActions.artistsLoaded(response.artists));
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load album\'s artists', error));
|
||||
@ -4348,7 +4364,7 @@ function toggleAlbumInLibrary(uri, method) {
|
||||
if (method == 'DELETE') var new_state = 0;
|
||||
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'me/albums?ids=' + helpers.getFromUri('albumid', uri), method).then(function (response) {
|
||||
request(dispatch, getState, 'me/albums?ids=' + helpers.getFromUri('albumid', uri), method).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ALBUM_FOLLOWING',
|
||||
key: uri,
|
||||
@ -4375,7 +4391,7 @@ function createPlaylist(name, description, is_public, is_collaborative) {
|
||||
collaborative: is_collaborative
|
||||
};
|
||||
|
||||
sendRequest(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/', 'POST', data).then(function (response) {
|
||||
request(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/', 'POST', data).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_LOADED',
|
||||
key: response.uri,
|
||||
@ -4409,12 +4425,12 @@ function savePlaylist(uri, name, description, is_public, is_collaborative, image
|
||||
collaborative: is_collaborative
|
||||
|
||||
// Update the playlist fields
|
||||
};sendRequest(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/' + helpers.getFromUri('playlistid', uri), 'PUT', data).then(function (response) {
|
||||
};request(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/' + helpers.getFromUri('playlistid', uri), 'PUT', data).then(function (response) {
|
||||
dispatch(uiActions.createNotification({ type: 'info', content: 'Playlist saved' }));
|
||||
|
||||
// Save the image
|
||||
if (image) {
|
||||
sendRequest(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/' + helpers.getFromUri('playlistid', uri) + '/images', 'PUT', image).then(function (response) {
|
||||
request(dispatch, getState, 'users/' + getState().spotify.me.id + '/playlists/' + helpers.getFromUri('playlistid', uri) + '/images', 'PUT', image).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: uri,
|
||||
@ -4452,7 +4468,7 @@ function getPlaylist(uri) {
|
||||
return function (dispatch, getState) {
|
||||
|
||||
// get the main playlist object
|
||||
sendRequest(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '?market=' + getState().spotify.country).then(function (response) {
|
||||
request(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '?market=' + getState().spotify.country).then(function (response) {
|
||||
|
||||
// convert links in description
|
||||
var description = null;
|
||||
@ -4500,7 +4516,7 @@ function getLibraryTracksAndPlay(uri) {
|
||||
|
||||
function getLibraryTracksAndPlayProcessor(data) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, data.next).then(function (response) {
|
||||
request(dispatch, getState, data.next).then(function (response) {
|
||||
|
||||
// Check to see if we've been cancelled
|
||||
if (getState().ui.processes['SPOTIFY_GET_LIBRARY_TRACKS_AND_PLAY_PROCESSOR'] !== undefined) {
|
||||
@ -4563,7 +4579,7 @@ function getPlaylistTracksAndPlay(uri, shuffle) {
|
||||
|
||||
function getPlaylistTracksAndPlayProcessor(data) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, data.next).then(function (response) {
|
||||
request(dispatch, getState, data.next).then(function (response) {
|
||||
|
||||
// Check to see if we've been cancelled
|
||||
if (getState().ui.processes['SPOTIFY_GET_PLAYLIST_TRACKS_AND_PLAY_PROCESSOR'] !== undefined) {
|
||||
@ -4620,7 +4636,7 @@ function toggleFollowingPlaylist(uri, method) {
|
||||
if (method == 'DELETE') var new_state = 0;
|
||||
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/followers', method).then(function (response) {
|
||||
request(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/followers', method).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_PLAYLIST_FOLLOWING_LOADED',
|
||||
key: uri,
|
||||
@ -4634,7 +4650,7 @@ function toggleFollowingPlaylist(uri, method) {
|
||||
|
||||
function addTracksToPlaylist(uri, tracks_uris) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'POST', { uris: tracks_uris }).then(function (response) {
|
||||
request(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'POST', { uris: tracks_uris }).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_TRACKS_ADDED',
|
||||
key: uri,
|
||||
@ -4649,7 +4665,7 @@ function addTracksToPlaylist(uri, tracks_uris) {
|
||||
|
||||
function deleteTracksFromPlaylist(uri, snapshot_id, tracks_indexes) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'DELETE', { snapshot_id: snapshot_id, positions: tracks_indexes }).then(function (response) {
|
||||
request(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'DELETE', { snapshot_id: snapshot_id, positions: tracks_indexes }).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_TRACKS_REMOVED',
|
||||
key: uri,
|
||||
@ -4664,7 +4680,7 @@ function deleteTracksFromPlaylist(uri, snapshot_id, tracks_indexes) {
|
||||
|
||||
function reorderPlaylistTracks(uri, range_start, range_length, insert_before, snapshot_id) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: insert_before, snapshot_id: snapshot_id }).then(function (response) {
|
||||
request(dispatch, getState, 'playlists/' + helpers.getFromUri('playlistid', uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: insert_before, snapshot_id: snapshot_id }).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_TRACKS_REORDERED',
|
||||
key: uri,
|
||||
@ -4712,7 +4728,7 @@ function getLibraryPlaylists() {
|
||||
|
||||
function getLibraryPlaylistsProcessor(data) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, data.next).then(function (response) {
|
||||
request(dispatch, getState, data.next).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_LIBRARY_PLAYLISTS_LOADED',
|
||||
playlists: response.items
|
||||
@ -4771,7 +4787,7 @@ function getLibraryArtists() {
|
||||
|
||||
function getLibraryArtistsProcessor(data) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, data.next).then(function (response) {
|
||||
request(dispatch, getState, data.next).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_LIBRARY_ARTISTS_LOADED',
|
||||
artists: response.artists.items
|
||||
@ -4829,7 +4845,7 @@ function getLibraryAlbums() {
|
||||
|
||||
function getLibraryAlbumsProcessor(data) {
|
||||
return function (dispatch, getState) {
|
||||
sendRequest(dispatch, getState, data.next).then(function (response) {
|
||||
request(dispatch, getState, data.next).then(function (response) {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_LIBRARY_ALBUMS_LOADED',
|
||||
albums: response.items
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -98,7 +98,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1538778332";
|
||||
var build = "1538878019";
|
||||
var version = "3.27.2";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -15,7 +15,7 @@ var helpers = require('../../helpers')
|
||||
* @param data mixed = request payload
|
||||
* @return Promise
|
||||
**/
|
||||
const sendRequest = (dispatch, getState, endpoint, method = 'GET', data = false) => {
|
||||
const request = (dispatch, getState, endpoint, method = 'GET', data = false) => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
getToken(dispatch, getState )
|
||||
@ -51,7 +51,7 @@ const sendRequest = (dispatch, getState, endpoint, method = 'GET', data = false)
|
||||
|
||||
// add reference to loader queue
|
||||
var loader_key = helpers.generateGuid()
|
||||
dispatch(uiActions.startLoading(loader_key, 'spotify_'+endpoint))
|
||||
dispatch(uiActions.startLoading(loader_key, 'spotify_'+endpoint));
|
||||
|
||||
$.ajax(config).then(
|
||||
response => {
|
||||
@ -120,6 +120,11 @@ function getToken(dispatch, getState){
|
||||
function refreshToken(dispatch, getState){
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// add reference to loader queue
|
||||
var loader_key = helpers.generateGuid();
|
||||
dispatch(uiActions.startLoading(loader_key, 'spotify_refresh_token'));
|
||||
|
||||
// Fully-authorized, so we can use the local Spotify credentials
|
||||
if (getState().spotify.authorization){
|
||||
|
||||
var config = {
|
||||
@ -132,6 +137,8 @@ function refreshToken(dispatch, getState){
|
||||
$.ajax(config)
|
||||
.then(
|
||||
response => {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
response.token_expiry = new Date().getTime() + (response.expires_in * 1000 )
|
||||
response.source = 'spotify'
|
||||
dispatch({
|
||||
@ -141,6 +148,8 @@ function refreshToken(dispatch, getState){
|
||||
resolve(response)
|
||||
},
|
||||
(xhr, status, error) => {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
reject({
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
@ -149,7 +158,9 @@ function refreshToken(dispatch, getState){
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Server-side authorized (with limited scope) so we need to refresh
|
||||
// using the Mopidy-Spotify credentials
|
||||
} else {
|
||||
|
||||
var config = {
|
||||
@ -162,6 +173,8 @@ function refreshToken(dispatch, getState){
|
||||
$.ajax(config)
|
||||
.then(
|
||||
(response, status, xhr) => {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
if (response.error){
|
||||
reject({
|
||||
config: config,
|
||||
@ -184,6 +197,8 @@ function refreshToken(dispatch, getState){
|
||||
|
||||
},
|
||||
(xhr, status, error) => {
|
||||
dispatch(uiActions.stopLoading(loader_key));
|
||||
|
||||
reject({
|
||||
config: config,
|
||||
xhr: xhr,
|
||||
@ -252,7 +267,7 @@ export function importAuthorization(authorization){
|
||||
**/
|
||||
export function getMe(){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'me' )
|
||||
request(dispatch, getState, 'me' )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -278,7 +293,7 @@ export function getMe(){
|
||||
**/
|
||||
export function getTrack(uri){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'tracks/'+ helpers.getFromUri('trackid', uri))
|
||||
request(dispatch, getState, 'tracks/'+ helpers.getFromUri('trackid', uri))
|
||||
.then(
|
||||
response => {
|
||||
dispatch(coreActions.trackLoaded(response));
|
||||
@ -295,7 +310,7 @@ export function getTrack(uri){
|
||||
|
||||
export function getLibraryTracks(){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'me/tracks?limit=50')
|
||||
request(dispatch, getState, 'me/tracks?limit=50')
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -334,7 +349,7 @@ export function getFeaturedPlaylists(){
|
||||
|
||||
var timestamp = year+'-'+month+'-'+day+'T'+hour+':'+min+':'+sec;
|
||||
|
||||
sendRequest(dispatch, getState, 'browse/featured-playlists?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale+'timestamp='+timestamp)
|
||||
request(dispatch, getState, 'browse/featured-playlists?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale+'timestamp='+timestamp)
|
||||
.then(
|
||||
response => {
|
||||
var playlists = []
|
||||
@ -379,7 +394,7 @@ export function getFeaturedPlaylists(){
|
||||
|
||||
export function getCategories(){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'browse/categories?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
request(dispatch, getState, 'browse/categories?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -399,7 +414,7 @@ export function getCategories(){
|
||||
|
||||
export function getCategory(id){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'browse/categories/'+id+'?country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
request(dispatch, getState, 'browse/categories/'+id+'?country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -425,7 +440,7 @@ export function getCategory(id){
|
||||
|
||||
export function getCategoryPlaylists(id){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'browse/categories/'+id+'/playlists?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
request(dispatch, getState, 'browse/categories/'+id+'/playlists?limit=50&country='+getState().spotify.country+'&locale='+getState().spotify.locale )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -446,7 +461,7 @@ export function getCategoryPlaylists(id){
|
||||
|
||||
export function getNewReleases(){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'browse/new-releases?country='+getState().spotify.country+'&limit=50' )
|
||||
request(dispatch, getState, 'browse/new-releases?country='+getState().spotify.country+'&limit=50' )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -466,7 +481,7 @@ export function getNewReleases(){
|
||||
|
||||
export function getURL(url, action_name, key = false){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, url )
|
||||
request(dispatch, getState, url )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -487,7 +502,7 @@ export function getURL(url, action_name, key = false){
|
||||
|
||||
export function getMore(url, core_action = null, custom_action = null){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, url)
|
||||
request(dispatch, getState, url)
|
||||
.then(
|
||||
response => {
|
||||
if (core_action){
|
||||
@ -538,7 +553,7 @@ export function getSearchResults(type, query, limit = 50, offset = 0){
|
||||
url += '&limit='+limit
|
||||
url += '&offset='+offset
|
||||
|
||||
sendRequest(dispatch, getState, url )
|
||||
request(dispatch, getState, url )
|
||||
.then(
|
||||
response => {
|
||||
if (response.tracks !== undefined){
|
||||
@ -628,7 +643,7 @@ export function getAutocompleteResults(field_id, query, types = ['album','artist
|
||||
endpoint += '&type='+types.join(',')
|
||||
endpoint += '&country='+getState().spotify.country
|
||||
|
||||
sendRequest(dispatch, getState, endpoint)
|
||||
request(dispatch, getState, endpoint)
|
||||
.then(
|
||||
response => {
|
||||
var genres = []
|
||||
@ -740,7 +755,7 @@ export function following(uri, method = 'GET'){
|
||||
break;
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, endpoint, method, data)
|
||||
request(dispatch, getState, endpoint, method, data)
|
||||
.then(
|
||||
response => {
|
||||
if (response ) is_following = response
|
||||
@ -777,7 +792,7 @@ export function resolveRadioSeeds(radio){
|
||||
artist_ids += helpers.getFromUri('artistid', radio.seed_artists[i])
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'artists?ids='+ artist_ids )
|
||||
request(dispatch, getState, 'artists?ids='+ artist_ids )
|
||||
.then(
|
||||
response => {
|
||||
if (response && response.artists){
|
||||
@ -805,7 +820,7 @@ export function resolveRadioSeeds(radio){
|
||||
track_ids += helpers.getFromUri('trackid', radio.seed_tracks[i])
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'tracks?ids='+ track_ids )
|
||||
request(dispatch, getState, 'tracks?ids='+ track_ids )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -842,8 +857,8 @@ export function getFavorites(limit = 50, term = 'long_term'){
|
||||
dispatch({type: 'SPOTIFY_FAVORITES_LOADED', artists: [], tracks: []})
|
||||
|
||||
$.when(
|
||||
sendRequest(dispatch, getState, 'me/top/artists?limit='+limit+'&time_range='+term),
|
||||
sendRequest(dispatch, getState, 'me/top/tracks?limit='+limit+'&time_range='+term)
|
||||
request(dispatch, getState, 'me/top/artists?limit='+limit+'&time_range='+term),
|
||||
request(dispatch, getState, 'me/top/tracks?limit='+limit+'&time_range='+term)
|
||||
|
||||
).then(
|
||||
(artists_response, tracks_response) => {
|
||||
@ -918,7 +933,7 @@ export function getRecommendations(uris = [], limit = 20, tunabilities = null){
|
||||
}
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, endpoint)
|
||||
request(dispatch, getState, endpoint)
|
||||
.then(
|
||||
response => {
|
||||
var tracks = Object.assign([], response.tracks);
|
||||
@ -991,7 +1006,7 @@ export function getRecommendations(uris = [], limit = 20, tunabilities = null){
|
||||
**/
|
||||
export function getGenres(){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'recommendations/available-genre-seeds')
|
||||
request(dispatch, getState, 'recommendations/available-genre-seeds')
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1032,7 +1047,7 @@ export function getArtist(uri, full = false){
|
||||
|
||||
// We need our artist, obviously
|
||||
var requests = [
|
||||
sendRequest(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) )
|
||||
request(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) )
|
||||
.then(
|
||||
response => {
|
||||
Object.assign(artist, response);
|
||||
@ -1050,7 +1065,7 @@ export function getArtist(uri, full = false){
|
||||
if (full){
|
||||
|
||||
requests.push(
|
||||
sendRequest(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
request(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
.then(
|
||||
response => {
|
||||
Object.assign(artist, response);
|
||||
@ -1065,7 +1080,7 @@ export function getArtist(uri, full = false){
|
||||
);
|
||||
|
||||
requests.push(
|
||||
sendRequest(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/related-artists' )
|
||||
request(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/related-artists' )
|
||||
.then(
|
||||
response => {
|
||||
dispatch(coreActions.artistsLoaded(response.artists));
|
||||
@ -1094,7 +1109,7 @@ export function getArtist(uri, full = false){
|
||||
|
||||
// Now go get our artist albums
|
||||
if (full){
|
||||
sendRequest(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/albums?market='+getState().spotify.country )
|
||||
request(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/albums?market='+getState().spotify.country )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1125,7 +1140,7 @@ export function getArtists(uris){
|
||||
ids += helpers.getFromUri('artistid', uris[i] );
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'artists/?ids='+ids )
|
||||
request(dispatch, getState, 'artists/?ids='+ids )
|
||||
.then(
|
||||
response => {
|
||||
for (var i = i; i < response.length; i++){
|
||||
@ -1163,7 +1178,7 @@ export function playArtistTopTracks(uri){
|
||||
|
||||
// We need to load the artist's top tracks first
|
||||
} else {
|
||||
sendRequest(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
request(dispatch, getState, 'artists/'+ helpers.getFromUri('artistid', uri) +'/top-tracks?country='+getState().spotify.country )
|
||||
.then(
|
||||
response => {
|
||||
const uris = helpers.arrayOf('uri',response.tracks)
|
||||
@ -1189,7 +1204,7 @@ export function playArtistTopTracks(uri){
|
||||
|
||||
export function getUser(uri){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri))
|
||||
request(dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri))
|
||||
.then(
|
||||
response => {
|
||||
dispatch(coreActions.userLoaded(helpers.formatUser(response)));
|
||||
@ -1208,7 +1223,7 @@ export function getUserPlaylists(uri){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// get the first page of playlists
|
||||
sendRequest(dispatch, getState, 'users/'+ helpers.getFromUri('userid', uri) +'/playlists?limit=40' )
|
||||
request(dispatch, getState, 'users/'+ helpers.getFromUri('userid', uri) +'/playlists?limit=40' )
|
||||
.then(
|
||||
response => {
|
||||
var playlists = [];
|
||||
@ -1260,7 +1275,7 @@ export function getAlbum(uri){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// get the album
|
||||
sendRequest(dispatch, getState, 'albums/'+ helpers.getFromUri('albumid', uri) )
|
||||
request(dispatch, getState, 'albums/'+ helpers.getFromUri('albumid', uri) )
|
||||
.then(
|
||||
response => {
|
||||
|
||||
@ -1299,7 +1314,7 @@ export function getAlbum(uri){
|
||||
}
|
||||
|
||||
// get all album artists as full objects
|
||||
sendRequest(dispatch, getState, 'artists/?ids='+artist_ids )
|
||||
request(dispatch, getState, 'artists/?ids='+artist_ids )
|
||||
.then(
|
||||
response => {
|
||||
dispatch(coreActions.artistsLoaded(response.artists));
|
||||
@ -1328,7 +1343,7 @@ export function toggleAlbumInLibrary(uri, method){
|
||||
if (method == 'DELETE' ) var new_state = 0
|
||||
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'me/albums?ids='+ helpers.getFromUri('albumid',uri), method )
|
||||
request(dispatch, getState, 'me/albums?ids='+ helpers.getFromUri('albumid',uri), method )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1366,7 +1381,7 @@ export function createPlaylist(name, description, is_public, is_collaborative){
|
||||
collaborative: is_collaborative
|
||||
}
|
||||
|
||||
sendRequest(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/', 'POST', data)
|
||||
request(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/', 'POST', data)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1411,7 +1426,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
}
|
||||
|
||||
// Update the playlist fields
|
||||
sendRequest(
|
||||
request(
|
||||
dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri), 'PUT', data)
|
||||
.then(
|
||||
response => {
|
||||
@ -1419,7 +1434,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
|
||||
// Save the image
|
||||
if (image){
|
||||
sendRequest(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri)+'/images', 'PUT', image)
|
||||
request(dispatch, getState, 'users/'+ getState().spotify.me.id +'/playlists/'+ helpers.getFromUri('playlistid',uri)+'/images', 'PUT', image)
|
||||
.then(
|
||||
|
||||
response => {
|
||||
@ -1470,7 +1485,7 @@ export function getPlaylist(uri){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// get the main playlist object
|
||||
sendRequest(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) +'?market='+getState().spotify.country )
|
||||
request(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) +'?market='+getState().spotify.country )
|
||||
.then(
|
||||
response => {
|
||||
|
||||
@ -1533,7 +1548,7 @@ export function getLibraryTracksAndPlay(uri){
|
||||
|
||||
export function getLibraryTracksAndPlayProcessor(data){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, data.next)
|
||||
request(dispatch, getState, data.next)
|
||||
.then(
|
||||
response => {
|
||||
|
||||
@ -1614,7 +1629,7 @@ export function getPlaylistTracksAndPlay(uri, shuffle){
|
||||
|
||||
export function getPlaylistTracksAndPlayProcessor(data){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, data.next)
|
||||
request(dispatch, getState, data.next)
|
||||
.then(
|
||||
response => {
|
||||
|
||||
@ -1685,7 +1700,7 @@ export function toggleFollowingPlaylist(uri, method){
|
||||
if (method == 'DELETE' ) var new_state = 0
|
||||
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/followers', method )
|
||||
request(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/followers', method )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1706,7 +1721,7 @@ export function toggleFollowingPlaylist(uri, method){
|
||||
|
||||
export function addTracksToPlaylist(uri, tracks_uris){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'POST', { uris: tracks_uris } )
|
||||
request(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'POST', { uris: tracks_uris } )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1728,7 +1743,7 @@ export function addTracksToPlaylist(uri, tracks_uris){
|
||||
|
||||
export function deleteTracksFromPlaylist(uri, snapshot_id, tracks_indexes){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'DELETE', { snapshot_id: snapshot_id, positions: tracks_indexes } )
|
||||
request(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'DELETE', { snapshot_id: snapshot_id, positions: tracks_indexes } )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1750,7 +1765,7 @@ export function deleteTracksFromPlaylist(uri, snapshot_id, tracks_indexes){
|
||||
|
||||
export function reorderPlaylistTracks(uri, range_start, range_length, insert_before, snapshot_id){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: insert_before, snapshot_id: snapshot_id } )
|
||||
request(dispatch, getState, 'playlists/'+ helpers.getFromUri('playlistid',uri) + '/tracks', 'PUT', { uri: uri, range_start: range_start, range_length: range_length, insert_before: insert_before, snapshot_id: snapshot_id } )
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1808,7 +1823,7 @@ export function getLibraryPlaylists(){
|
||||
|
||||
export function getLibraryPlaylistsProcessor(data){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, data.next)
|
||||
request(dispatch, getState, data.next)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1879,7 +1894,7 @@ export function getLibraryArtists(){
|
||||
|
||||
export function getLibraryArtistsProcessor(data){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, data.next)
|
||||
request(dispatch, getState, data.next)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
@ -1949,7 +1964,7 @@ export function getLibraryAlbums(){
|
||||
|
||||
export function getLibraryAlbumsProcessor(data){
|
||||
return (dispatch, getState) => {
|
||||
sendRequest(dispatch, getState, data.next)
|
||||
request(dispatch, getState, data.next)
|
||||
.then(
|
||||
response => {
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user