Browse Source

preserve order of notifications

activeAddress
Ivan Socolsky 10 years ago
parent
commit
226f18d345
  1. 36
      lib/server.js

36
lib/server.js

@ -424,24 +424,24 @@ WalletService.prototype.joinWallet = function(opts, cb) {
if (err) return cb(err); if (err) return cb(err);
async.parallel([ async.series([
function(done) { function(next) {
self._notify('NewCopayer', { self._notify('NewCopayer', {
walletId: opts.walletId, walletId: opts.walletId,
copayerId: copayer.id, copayerId: copayer.id,
copayerName: copayer.name, copayerName: copayer.name,
}, done); }, next);
}, },
function(done) { function(next) {
if (wallet.isComplete() && wallet.isShared()) { if (wallet.isComplete() && wallet.isShared()) {
self._notify('WalletComplete', { self._notify('WalletComplete', {
walletId: opts.walletId, walletId: opts.walletId,
}, { }, {
isGlobal: true isGlobal: true
}, done); }, next);
} else { } else {
done(); next();
} }
}, },
], function() { ], function() {
@ -951,21 +951,21 @@ WalletService.prototype.signTx = function(opts, cb) {
self.storage.storeTx(self.walletId, txp, function(err) { self.storage.storeTx(self.walletId, txp, function(err) {
if (err) return cb(err); if (err) return cb(err);
async.parallel([ async.series([
function(done) { function(next) {
self._notify('TxProposalAcceptedBy', { self._notify('TxProposalAcceptedBy', {
txProposalId: opts.txProposalId, txProposalId: opts.txProposalId,
copayerId: self.copayerId, copayerId: self.copayerId,
}, done); }, next);
}, },
function(done) { function(next) {
if (txp.isAccepted()) { if (txp.isAccepted()) {
self._notify('TxProposalFinallyAccepted', { self._notify('TxProposalFinallyAccepted', {
txProposalId: opts.txProposalId, txProposalId: opts.txProposalId,
}, done); }, next);
} else { } else {
done(); next();
} }
}, },
], function() { ], function() {
@ -1052,21 +1052,21 @@ WalletService.prototype.rejectTx = function(opts, cb) {
self.storage.storeTx(self.walletId, txp, function(err) { self.storage.storeTx(self.walletId, txp, function(err) {
if (err) return cb(err); if (err) return cb(err);
async.parallel([ async.series([
function(done) { function(next) {
self._notify('TxProposalRejectedBy', { self._notify('TxProposalRejectedBy', {
txProposalId: opts.txProposalId, txProposalId: opts.txProposalId,
copayerId: self.copayerId, copayerId: self.copayerId,
}, done); }, next);
}, },
function(done) { function(next) {
if (txp.status == 'rejected') { if (txp.status == 'rejected') {
self._notify('TxProposalFinallyRejected', { self._notify('TxProposalFinallyRejected', {
txProposalId: opts.txProposalId, txProposalId: opts.txProposalId,
}, done); }, next);
} else { } else {
done(); next();
} }
}, },
], function() { ], function() {

Loading…
Cancel
Save