Skip to content

Commit

Permalink
remove the isLoved helper
Browse files Browse the repository at this point in the history
Rayman committed Oct 11, 2014
1 parent 2ed873d commit 6da8444
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions client/views/playlists/playlist.js
Original file line number Diff line number Diff line change
@@ -177,18 +177,6 @@ Template.playlist.events = {
},
};

Template.loveSong.isLoved = function() {
var videoId = this._id;
var user = Meteor.user();
if (!user)
return;
var i = user.profile.lovedSongs.indexOf(videoId);
if (i<0)
return ""; //not loved
else
return "loved"; //return classname
};

Template.updatePlaylistForm.editingDoc = function () {
return Playlists.findOne({_id: this._id});
};
@@ -425,6 +413,8 @@ Template.songs.songs = function() {
return u.profile.playing.playlistIndex;
});

var lovedSongs = Meteor.user().profile.lovedSongs;

// find all songs for this playlist
var ids = _.pluck(this.songs, 'songId');
var songDB = _.indexBy(
@@ -453,6 +443,9 @@ Template.songs.songs = function() {
song.author = authorDB[entry.author];
song.addedFromNow = entry.added ? moment(entry.added).fromNow() : "";

// check if this song is loved by the user
song.isLoved = (_.contains(lovedSongs, entry.songId)) ? 'loved' : '';

return song;
});

0 comments on commit 6da8444

Please sign in to comment.