From 82b0fe76359ccd20b332a512b7103e5f8170c9b9 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Sat, 18 Jun 2016 21:59:17 +0200 Subject: [PATCH] Fix merging algo --- www/assets/js/sofia.db.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/www/assets/js/sofia.db.js b/www/assets/js/sofia.db.js index 1d16841..73533c6 100644 --- a/www/assets/js/sofia.db.js +++ b/www/assets/js/sofia.db.js @@ -219,12 +219,24 @@ S.db.fiches = { } }); $.each(n.events, function(id,val){ + /* if ($.inArray(val,ret.events) === -1) { //Not found ret.events.push(val); } + */ + var found = false; + var searching = JSON.stringify(val); + $.each(ret.events, function(i,v){ + if(!found && JSON.stringify(v) === searching ){ + found = true; + } + }); + if(!found){ + ret.events.push(val); + } }); ret.events.sort(function(x, y){ //Order - return x.timestamp - y.timestamp; + return x.timestamp - y.timestamp; }); /* */ ret._rev=o._rev;