angular.module('app.services').factory('favorite',
  function ($http, serverConfig) {
    var _bookmarks = []
    return {
      load: function(){
        return $http.get(serverConfig.url + '/api/bookmarks/list/all/1').then(function(response){
          _bookmarks = response.data.items
          return(response.data.items)
        })
      },

      isBookmarked: function(activity){
        var bookmarkedIDs = _bookmarks.map(function(b){
          return(b.item_id)
        })
        var aID = activity.get('entity').id
        return bookmarkedIDs.includes(aID)
      },
      addBookmark: function(activity){
        var aID = activity.get('entity').id
        var aType = activity.get('entity').type
        if(aType == 'micro-petition'){
          var hasTitle = activity.get('title') && activity.get('title').length > 0
          if(hasTitle)
            aType = 'petition'
          else
            aType = 'post'
        }
        var that = this
        
        $http.post(serverConfig.url + '/api/bookmarks/add/'+aType+'/'+aID).then(function(){
          that.load()
        })
      },

      removeBookmark: function(activity){
        var aID = activity.get('entity').id
        $http.delete(serverConfig.url + '/api/bookmarks/remove/'+aID).then(function(){
          that.load()
        })        
      }
    }
  });

@@ -1132,32 +1132,56 @@
 tion(activity)%7B%0A
+        var that = this%0A
         var aID 
@@ -1200,32 +1200,161 @@
 et('entity').id%0A
+        var bookmark =  _bookmarks.find(function(b)%7B%0A          return(b.item_id = aID)%0A        %7D)%0A        var bID = bookmark.id%0A%0A
         $http.de
@@ -1402,17 +1402,17 @@
 emove/'+
-a
+b
 ID).then

fix remove bookmark API call id