Using API v1.
Not sure how frequently I'll have to do stuff like this, but I suspect a fair bit.
I want to check if the user is the owner of a playlist dropped. Is it possible to do this without the nested load chaining below? I see that Promises can be joined, but I don't think I can load currentUser
without having already loaded owner
. Any way to simplify this?
var drop = models.Playlist.fromURI(...);
var success_message = document.createElement('p');
success_message.innerHTML = 'Playlist successfully dropped: ' + drop.uri;
this.appendChild(success_message);
drop.load('owner').done(function (playlist) {
playlist.owner.load('currentUser').done(function (owner) {
if (owner.currentUser) {
var allowed_message = document.createElement('p');
allowed_message.innerHTML = 'You are the owner of this playlist, let\'s get to work!';
drop_box.appendChild(allowed_message);
}
else {
var disallowed_message = document.createElement('p');
disallowed_message.innerHTML = 'You are not the owner of this playlist, choose a different one please!';
drop_box.appendChild(disallowed_message);
}
});
});