Skip to content

Commit 6da8444

Browse files
committed
remove the isLoved helper
1 parent 2ed873d commit 6da8444

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

client/views/playlists/playlist.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ Template.playlist.events = {
177177
},
178178
};
179179

180-
Template.loveSong.isLoved = function() {
181-
var videoId = this._id;
182-
var user = Meteor.user();
183-
if (!user)
184-
return;
185-
var i = user.profile.lovedSongs.indexOf(videoId);
186-
if (i<0)
187-
return ""; //not loved
188-
else
189-
return "loved"; //return classname
190-
};
191-
192180
Template.updatePlaylistForm.editingDoc = function () {
193181
return Playlists.findOne({_id: this._id});
194182
};
@@ -425,6 +413,8 @@ Template.songs.songs = function() {
425413
return u.profile.playing.playlistIndex;
426414
});
427415

416+
var lovedSongs = Meteor.user().profile.lovedSongs;
417+
428418
// find all songs for this playlist
429419
var ids = _.pluck(this.songs, 'songId');
430420
var songDB = _.indexBy(
@@ -453,6 +443,9 @@ Template.songs.songs = function() {
453443
song.author = authorDB[entry.author];
454444
song.addedFromNow = entry.added ? moment(entry.added).fromNow() : "";
455445

446+
// check if this song is loved by the user
447+
song.isLoved = (_.contains(lovedSongs, entry.songId)) ? 'loved' : '';
448+
456449
return song;
457450
});
458451

0 commit comments

Comments
 (0)