+ favorite-song data-song-id="{{ track.id }}" favorite="track.user_favorite" count="track.favoritings_count">
{{track.user_favorite ? 'Liked' : 'Like'}}
{{track.user_favorite ? 'Unlike' : 'Like'}}
diff --git a/app/public/js/common/favoriteSongDirective.js b/app/public/js/common/favoriteSongDirective.js index 185774c5..d1ed3e95 100644 --- a/app/public/js/common/favoriteSongDirective.js +++ b/app/public/js/common/favoriteSongDirective.js @@ -8,7 +8,8 @@ app.directive('favoriteSong', function( return { restrict: 'A', scope: { - favorite: "=" + favorite: "=", + count: "=" }, link: function($scope, elem, attrs) { var userId @@ -25,6 +26,7 @@ app.directive('favoriteSong', function( if ( typeof status == "object" ) { notificationFactory.success("Song removed from likes!"); $scope.favorite = false; + $scope.count -= 1; } }, function() { notificationFactory.error("Something went wrong!"); @@ -35,6 +37,7 @@ app.directive('favoriteSong', function( if ( typeof status == "object" ) { notificationFactory.success("Song added to likes!"); $scope.favorite = true; + $scope.count += 1; } }, function(status) { notificationFactory.error("Something went wrong!"); diff --git a/app/public/stylesheets/sass/_components/_track.scss b/app/public/stylesheets/sass/_components/_track.scss index 66252512..44db95f4 100644 --- a/app/public/stylesheets/sass/_components/_track.scss +++ b/app/public/stylesheets/sass/_components/_track.scss @@ -1,4 +1,11 @@ .trackView { + & .likes_count { + &.liked { + & > i { + color: $scColor; + } + } + } & .trackDetails { display: flex; diff --git a/app/views/common/tracks.html b/app/views/common/tracks.html index 48b2aa1b..e7be0712 100644 --- a/app/views/common/tracks.html +++ b/app/views/common/tracks.html @@ -51,7 +51,7 @@