make explicit refreshes when storing wallet

This commit is contained in:
Manuel Araoz 2014-05-09 11:59:38 -03:00
commit 22cd4cae94
2 changed files with 25 additions and 29 deletions

View file

@ -127,7 +127,6 @@ Wallet.prototype._handleNetworkChange = function(newCopayerId) {
this.sendWalletId(newCopayerId); this.sendWalletId(newCopayerId);
this.emit('peer', this.network.peerFromCopayer(newCopayerId)); this.emit('peer', this.network.peerFromCopayer(newCopayerId));
} }
this.emit('refresh');
}; };
@ -231,17 +230,10 @@ Wallet.prototype.getRegisteredPeerIds = function() {
return this.registeredPeerIds; return this.registeredPeerIds;
}; };
Wallet.prototype.store = function(isSync) { Wallet.prototype.store = function() {
var wallet = this.toObj(); var wallet = this.toObj();
this.storage.setFromObj(this.id, wallet); this.storage.setFromObj(this.id, wallet);
this.log('Wallet stored');
if (isSync) {
this.log('Wallet stored.'); //TODO
} else {
this.log('Wallet stored. REFRESH Emitted'); //TODO
this.emit('refresh');
}
}; };
Wallet.prototype.toObj = function() { Wallet.prototype.toObj = function() {
@ -319,7 +311,8 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
Wallet.prototype.generateAddress = function(isChange) { Wallet.prototype.generateAddress = function(isChange) {
var addr = this.publicKeyRing.generateAddress(isChange); var addr = this.publicKeyRing.generateAddress(isChange);
this.sendPublicKeyRing(); this.sendPublicKeyRing();
this.store(true); this.store();
this.emit('refresh');
return addr; return addr;
}; };
@ -346,7 +339,8 @@ Wallet.prototype.reject = function(ntxid) {
txp.rejectedBy[myId] = Date.now(); txp.rejectedBy[myId] = Date.now();
this.sendTxProposals(); this.sendTxProposals();
this.store(true); this.store();
this.emit('refresh');
}; };
@ -363,14 +357,14 @@ Wallet.prototype.sign = function(ntxid) {
var before = b.signaturesAdded; var before = b.signaturesAdded;
b.sign(keys); b.sign(keys);
var ret = false;
if (b.signaturesAdded > before) { if (b.signaturesAdded > before) {
txp.signedBy[myId] = Date.now(); txp.signedBy[myId] = Date.now();
this.sendTxProposals(); this.sendTxProposals();
this.store(true); this.store();
ret = true; this.emit('refresh');
return true;
} }
return ret; return false;
}; };
Wallet.prototype.sendTx = function(ntxid, cb) { Wallet.prototype.sendTx = function(ntxid, cb) {

View file

@ -80,6 +80,7 @@ angular.module('copay.controllerUtils')
$location.path('addresses'); $location.path('addresses');
}); });
w.on('refresh', function() { w.on('refresh', function() {
//alert('refresh');
root.updateBalance(function() { root.updateBalance(function() {
$rootScope.$digest(); $rootScope.$digest();
}); });
@ -93,6 +94,7 @@ angular.module('copay.controllerUtils')
w.on('openError', root.onErrorDigest); w.on('openError', root.onErrorDigest);
w.on('peer', function(peerID) { w.on('peer', function(peerID) {
video.callPeer(peerID, handlePeerVideo); video.callPeer(peerID, handlePeerVideo);
$rootScope.$digest();
}); });
w.on('close', root.onErrorDigest); w.on('close', root.onErrorDigest);
w.netStart(); w.netStart();