diff --git a/js/models/Storage.js b/js/models/Storage.js index 79c5c117b..3747971de 100644 --- a/js/models/Storage.js +++ b/js/models/Storage.js @@ -258,9 +258,14 @@ Storage.prototype.getWallets2 = function(cb) { Storage.prototype.getWallets = function(cb) { var self = this; - self.getWallets2(function(wallets1) { + self.getWallets2(function(wallets) { self.getWallets_Old(function(wallets2) { - return cb(wallets1.concat(wallets2)); + var ids = _.pluck(wallets, 'id'); + _.each(wallets2, function(w) { + if (!_.contains(ids, w.id)) + wallets.push(w); + }); + return cb(wallets); }); }) }; diff --git a/test/test.Storage.js b/test/test.Storage.js index 97fd90282..6e76213e3 100644 --- a/test/test.Storage.js +++ b/test/test.Storage.js @@ -217,22 +217,24 @@ describe('Storage model', function() { s.setFromObj('1', w1, function() { s.setFromObj('2', w2, function() { s._write('3::name', 'matias', function() { - s.setGlobal('nameFor::3', 'wallet3', function() { - s.getWallets(function(ws) { - ws.length.should.equal(3); - ws[0].should.deep.equal({ - id: '1', - name: 'wallet1', + s._write('1::name', 'juan', function() { + s.setGlobal('nameFor::3', 'wallet3', function() { + s.getWallets(function(ws) { + ws.length.should.equal(3); + ws[0].should.deep.equal({ + id: '1', + name: 'wallet1', + }); + ws[1].should.deep.equal({ + id: '2', + name: undefined + }); + ws[2].should.deep.equal({ + id: '3', + name: 'wallet3', + }); + done(); }); - ws[1].should.deep.equal({ - id: '2', - name: undefined - }); - ws[2].should.deep.equal({ - id: '3', - name: 'wallet3', - }); - done(); }); }); })