Skip to content

Commit

Permalink
Fixed a bug in SearchSource.prototype._updateStore. Resolves #7, #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Howon Song committed Apr 7, 2015
1 parent 8af2d69 commit 38cb9a7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ SearchSource.prototype._updateStore = function(data) {
self.store.update(item._id, item, {upsert: true});
});

var removedItem = _.difference(storeIds, currentIds);
removedItem.forEach(function(id) {
// Remove items in client DB that we no longer need
var currentIdStrs = _.map(currentIds, function(currentId){
return currentId._str;
});
var removedItems = _.reject(storeIds, function(storeId) {
return _.contains(currentIdStrs, storeId._str);
});
removedItems.forEach(function(id) {
self.store.remove(id);
});
};
Expand Down

0 comments on commit 38cb9a7

Please sign in to comment.