Skip to content

Commit

Permalink
Update row impacts when a pocket is deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
caedesvvv committed Jan 22, 2015
1 parent 52a8204 commit d38be46
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/js/model/pocket/base.js
Expand Up @@ -121,6 +121,16 @@ BasePocket.prototype.destroy = function() {
// Now delete our index in the wallet
var pocketId = this.getPocketId();
delete wallet.pockets.pockets[this.type][pocketId];

// Cleanup impact
wallet.identity.history.history.forEach(function(historyRow) {
var impact = historyRow.impact;
if (impact && impact.hasOwnProperty(pocketId) && impact[pocketId].type === self.type) {
delete impact[pocketId];
}
});

// Save
wallet.store.save();
return removed;
};
Expand Down
3 changes: 3 additions & 0 deletions test/unit/model/walletSpec.js
Expand Up @@ -97,6 +97,9 @@ define(['model/wallet', 'bitcoinjs-lib'], function(Wallet, Bitcoin) {
},
save: function() {
}
},
history: {
history: []
}
};
wallet = new Wallet(identity.store, identity);
Expand Down

0 comments on commit d38be46

Please sign in to comment.