fix join sync

This commit is contained in:
Matias Alejo Garcia 2014-12-02 17:32:32 -03:00
commit 8d7783cac3
4 changed files with 25 additions and 16 deletions

View file

@ -2,12 +2,15 @@
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope) {
$scope.init = function() {
$rootScope.title = 'Home';
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
// This is necesarry, since wallet can change in homeWallet, without running init() again.
$rootScope.$watch('wallet', function() {
if ($rootScope.wallet && $rootScope.wallet.isComplete()) {
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
}
});
};
});

View file

@ -474,6 +474,8 @@ Identity.importFromFullJson = function(str, password, opts, cb) {
* @emits newWallet (walletId)
*/
Identity.prototype.bindWallet = function(w) {
preconditions.checkArgument(w && this.wallets[w.getId()]);
var self = this;
log.debug('Binding wallet:' + w.getName());
@ -571,13 +573,10 @@ Identity.prototype.createWallet = function(opts, cb) {
opts.version = opts.version || this.version;
var self = this;
var w = new walletClass(opts);
self.wallets[w.getId()] = w;
self.updateFocusedTimestamp(w.getId());
self.bindWallet(w);
self.updateFocusedTimestamp(w.getId());
self.storeWallet(w, function(err) {
if (err) return cb(err);

View file

@ -332,15 +332,17 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
return;
}
if (hasChanged) {
if (wasIncomplete) {
this.sendPublicKeyRing();
}
if (this.publicKeyRing.isComplete()) {
this._lockIncomming();
}
this.emitAndKeepAlive('ready');
} else {
this.emitAndKeepAlive('publicKeyRingUpdated');
}
}
};
/**
@ -957,7 +959,7 @@ Wallet.prototype.netStart = function() {
}
log.debug('Wallet:' + self.id + ' Starting network.');
this.network.start(startOpts, function() {
self.emitAndKeepAlive('ready');
self.emitAndKeepAlive(self.isComplete() ? 'ready' : 'waitingCopayers');
});
};
@ -1400,7 +1402,8 @@ Wallet.prototype.getPendingTxProposalsCount = function() {
var txps = this.txProposals.txps;
var maxRejectCount = this.maxRejectCount();
var myId = this.getMyCopayerId();
var pending =0, pendingForUs = 0;
var pending = 0,
pendingForUs = 0;
_.each(txps, function(inTxp, ntxid) {
if (!inTxp.isPending(maxRejectCount))
@ -1848,7 +1851,6 @@ Wallet.prototype._getPayProRefundOutputs = function(txp) {
log.warn('no remainder set. Not setting refund in PayPro');
return;
}
console.log('[Wallet.js.1842:builder:]',txp.builder.vanilla.opts); //TODO
var addrStr = opts.remainderOut.address;
var addr = new bitcore.Address(addrStr);
var script = bitcore.Script.createP2SH(addr.payload()).getBuffer();

View file

@ -164,6 +164,11 @@ angular.module('copayApp.services')
notification.error('Error', $filter('translate')('Received corrupt message from ') + peerId);
}
});
w.on('publicKeyRingUpdated', function() {
$rootScope.$digest();
});
w.on('ready', function() {
var isFocused = root.isFocused(wid);
copay.logger.debug('Wallet:' + w.getName() + ' is ready. Focused:', isFocused);