From a840685120a2cfc65780d011673e414d81c6fbef Mon Sep 17 00:00:00 2001 From: Mc Date: Wed, 2 Mar 2016 20:33:33 +0100 Subject: [PATCH 1/2] Liked playlists. --- app/js/actions/actionCreators.js | 12 +++++++----- app/js/utils/soundcloud.js | 30 ++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/app/js/actions/actionCreators.js b/app/js/actions/actionCreators.js index a7361e0..517bc0b 100644 --- a/app/js/actions/actionCreators.js +++ b/app/js/actions/actionCreators.js @@ -183,16 +183,18 @@ actions = McFly.createActions({ fetchPlaylists: function() { return SoundCloud.fetchPlaylists() .then(function(playlists) { - return { - 'actionType' : 'LOADED_PLAYLISTS', - 'playlists' : playlists - } + return SoundCloud.fetchPlaylistLikes() + .then(function(likes) { + return { + 'actionType' : 'LOADED_PLAYLISTS', + 'playlists' : playlists.concat(likes) + } + }) }) .catch(function(ex) { console.error(ex) }) }, - }) module.exports = actions diff --git a/app/js/utils/soundcloud.js b/app/js/utils/soundcloud.js index 910c034..a3407c7 100644 --- a/app/js/utils/soundcloud.js +++ b/app/js/utils/soundcloud.js @@ -145,16 +145,34 @@ SoundCloud.prototype.fetchFeed = function(options) { }) } +SoundCloud.prototype._fetchPlaylists = function(resp) { + return resp.map(this._mapTrack) + .map(function(playlist) { + playlist.tracks = _.map(playlist.tracks, function(track) { + return this._mapTrack(track) + }.bind(this)) + return playlist + }) +} + SoundCloud.prototype.fetchPlaylists = function() { return this.makeRequest('me/playlists') .then() .bind(this) - .map(this._mapTrack) - .map(function(playlist) { - playlist.tracks = _.map(playlist.tracks, function(track) { - return this._mapTrack(track) - }.bind(this)) - return playlist + .then(funtion(playlists) { + return this._fetchPlaylists(playlists) + }) +} + +SoundCloud.prototype.fetchPlaylistLikes = function() { + return this.makeRequest('e1/me/playlist_likes') + .then() + .bind(this) + .map(function(resp) { + return resp.playlist + }) + .then(funtion(playlists) { + return this._fetchPlaylists(playlists) }) } From c19326fa276990c3e347696b0186d515af9c5f51 Mon Sep 17 00:00:00 2001 From: Mc Date: Wed, 2 Mar 2016 21:12:27 +0100 Subject: [PATCH 2/2] Fix typo. Revert without function. --- app/js/utils/soundcloud.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/js/utils/soundcloud.js b/app/js/utils/soundcloud.js index a3407c7..87f2129 100644 --- a/app/js/utils/soundcloud.js +++ b/app/js/utils/soundcloud.js @@ -145,22 +145,16 @@ SoundCloud.prototype.fetchFeed = function(options) { }) } -SoundCloud.prototype._fetchPlaylists = function(resp) { - return resp.map(this._mapTrack) - .map(function(playlist) { - playlist.tracks = _.map(playlist.tracks, function(track) { - return this._mapTrack(track) - }.bind(this)) - return playlist - }) -} - SoundCloud.prototype.fetchPlaylists = function() { return this.makeRequest('me/playlists') .then() .bind(this) - .then(funtion(playlists) { - return this._fetchPlaylists(playlists) + .map(this._mapTrack) + .map(function(playlist) { + playlist.tracks = _.map(playlist.tracks, function(track) { + return this._mapTrack(track) + }.bind(this)) + return playlist }) } @@ -171,8 +165,12 @@ SoundCloud.prototype.fetchPlaylistLikes = function() { .map(function(resp) { return resp.playlist }) - .then(funtion(playlists) { - return this._fetchPlaylists(playlists) + .map(this._mapTrack) + .map(function(playlist) { + playlist.tracks = _.map(playlist.tracks, function(track) { + return this._mapTrack(track) + }.bind(this)) + return playlist }) }