File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -177,18 +177,6 @@ Template.playlist.events = {
177
177
} ,
178
178
} ;
179
179
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
-
192
180
Template . updatePlaylistForm . editingDoc = function ( ) {
193
181
return Playlists . findOne ( { _id : this . _id } ) ;
194
182
} ;
@@ -425,6 +413,8 @@ Template.songs.songs = function() {
425
413
return u . profile . playing . playlistIndex ;
426
414
} ) ;
427
415
416
+ var lovedSongs = Meteor . user ( ) . profile . lovedSongs ;
417
+
428
418
// find all songs for this playlist
429
419
var ids = _ . pluck ( this . songs , 'songId' ) ;
430
420
var songDB = _ . indexBy (
@@ -453,6 +443,9 @@ Template.songs.songs = function() {
453
443
song . author = authorDB [ entry . author ] ;
454
444
song . addedFromNow = entry . added ? moment ( entry . added ) . fromNow ( ) : "" ;
455
445
446
+ // check if this song is loved by the user
447
+ song . isLoved = ( _ . contains ( lovedSongs , entry . songId ) ) ? 'loved' : '' ;
448
+
456
449
return song ;
457
450
} ) ;
458
451
You can’t perform that action at this time.
0 commit comments