Skip to content

Liked playlists. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app/js/actions/actionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions app/js/utils/soundcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ SoundCloud.prototype.fetchPlaylists = function() {
})
}

SoundCloud.prototype.fetchPlaylistLikes = function() {
return this.makeRequest('e1/me/playlist_likes')
.then()
.bind(this)
.map(function(resp) {
return resp.playlist
})
.map(this._mapTrack)
.map(function(playlist) {
playlist.tracks = _.map(playlist.tracks, function(track) {
return this._mapTrack(track)
}.bind(this))
return playlist
})
}

SoundCloud.prototype.expandPlaylist = function(playlist) {
if (!playlist.hasOwnProperty('tracks_uri') || playlist.kind !== 'playlist')
return
Expand Down