From d0401257f666ad8cbda054c5e7ec46524a832636 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 12 Apr 2016 22:15:58 +0200 Subject: Fix #465 --- js/service/ItemResource.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'js/service/ItemResource.js') diff --git a/js/service/ItemResource.js b/js/service/ItemResource.js index 0f15a21c5..167efd5f3 100644 --- a/js/service/ItemResource.js +++ b/js/service/ItemResource.js @@ -23,6 +23,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, this.starredCount = 0; this.lowestId = 0; this.highestId = 0; + this.fingerprints = {}; Resource.prototype.clear.call(this); }; @@ -39,6 +40,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, default: var self = this; + var importValues = []; value.forEach(function (item) { // initialize lowest and highest id if (self.lowestId === 0) { @@ -54,9 +56,15 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL, if (item.id < self.lowestId) { self.lowestId = item.id; } + + // filter out duplicates + if (self.fingerprints[item.fingerprint] === undefined) { + self.fingerprints[item.fingerprint] = true; + importValues.push(item); + } }); - Resource.prototype.receive.call(this, value, channel); + Resource.prototype.receive.call(this, importValues, channel); } }; -- cgit v1.2.3