Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
better duplicate handling for batchLoadItems
Browse files Browse the repository at this point in the history
  • Loading branch information
bkoski committed Nov 3, 2014
1 parent e4a649f commit 9ae2ba7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pourover.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,6 @@ var PourOver = (function(){
return _(items).pluck("guid");
},

// Note that if you pass a duplicate guid when batchLoadingItems,
// it will be added twice.
batchLoadItems: function(data){
this.trigger("will_incremental_change");
var new_cids = [],
Expand All @@ -717,6 +715,11 @@ var PourOver = (function(){
item.cid = last_id++;
new_cids.push(item.cid);
this.items = this.items.concat([item]);

// add this to the list of existing items so that
// if data contains the same guid multiple times,
// the second instance will be treated as an update.
old_items[item.guid] = item;
}
},this))

Expand Down

0 comments on commit 9ae2ba7

Please sign in to comment.