Wallets in both formats only get listed once
This commit is contained in:
parent
861c1882df
commit
48c3633ece
2 changed files with 24 additions and 17 deletions
|
|
@ -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);
|
||||
});
|
||||
})
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue