Resume/OnLine events do not display notifications

This commit is contained in:
Gustavo Maximiliano Cortez 2015-06-12 17:01:13 -03:00
commit 80beebf928
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF

View file

@ -57,8 +57,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
isoCode: 'pt', isoCode: 'pt',
}]; }];
self.setOngoingProcess = function(processName, isOn) { self.setOngoingProcess = function(processName, isOn, quiet) {
$log.debug('onGoingProcess', processName, isOn); $log.debug('onGoingProcess', processName, isOn);
if (quiet) return;
self[processName] = isOn; self[processName] = isOn;
self.onGoingProcess[processName] = isOn; self.onGoingProcess[processName] = isOn;
@ -176,22 +177,23 @@ angular.module('copayApp.controllers').controller('indexController', function($r
return bal; return bal;
}; };
self.updateAll = function(walletStatus, untilItChanges, initStatusHash, tries) { self.updateAll = function(obj, initStatusHash, tries) {
tries = tries || 0; tries = tries || 0;
if (untilItChanges && lodash.isUndefined(initStatusHash)) { var quiet = (obj && obj.quiet) ? true : null;
if (obj && obj.untilItChanges && lodash.isUndefined(initStatusHash)) {
initStatusHash = _walletStatusHash(); initStatusHash = _walletStatusHash();
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash) $log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
} }
var get = function(cb) { var get = function(cb) {
if (walletStatus) if (obj && obj.walletStatus)
return cb(null, walletStatus); return cb(null, obj.walletStatus);
else { else {
self.updateError = false; self.updateError = false;
return fc.getStatus(function(err, ret) { return fc.getStatus(function(err, ret) {
if (err) { if (err) {
self.updateError = true; self.updateError = true;
} else { } else {
self.setOngoingProcess('scanning', ret.wallet.scanning); self.setOngoingProcess('scanning', ret.wallet.scanning, quiet);
} }
return cb(err, ret); return cb(err, ret);
}); });
@ -202,18 +204,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
if (!fc) return; if (!fc) return;
$timeout(function() { $timeout(function() {
self.setOngoingProcess('updatingStatus', true); self.setOngoingProcess('updatingStatus', true, quiet);
$log.debug('Updating Status:', fc, tries); $log.debug('Updating Status:', fc, tries);
get(function(err, walletStatus) { get(function(err, walletStatus) {
var currentStatusHash = _walletStatusHash(walletStatus); var currentStatusHash = _walletStatusHash(walletStatus);
$log.debug('Status update. hash:' + currentStatusHash + ' Try:'+ tries); $log.debug('Status update. hash:' + currentStatusHash + ' Try:'+ tries);
if (!err && untilItChanges && initStatusHash == currentStatusHash && tries < 7) { if (!err && (obj && obj.untilItChanges) && initStatusHash == currentStatusHash && tries < 7) {
return $timeout(function() { return $timeout(function() {
$log.debug('Retrying update... Try:' + tries) $log.debug('Retrying update... Try:' + tries)
return self.updateAll(null, true, initStatusHash, ++tries); return self.updateAll({walletStatus: null, untilItChanges: true}, initStatusHash, ++tries);
}, 1400 * tries); }, 1400 * tries);
} }
self.setOngoingProcess('updatingStatus', false); self.setOngoingProcess('updatingStatus', false, quiet);
if (err) { if (err) {
self.handleError(err); self.handleError(err);
return; return;
@ -329,7 +331,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
return; return;
} }
$log.debug('Wallet Opened'); $log.debug('Wallet Opened');
self.updateAll(lodash.isObject(walletStatus) ? walletStatus : null); self.updateAll(lodash.isObject(walletStatus) ? {walletStatus: walletStatus} : null);
$rootScope.$apply(); $rootScope.$apply();
}); });
}); });
@ -634,7 +636,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
self.debouncedUpdate = lodash.throttle(function() { self.debouncedUpdate = lodash.throttle(function() {
self.updateAll(); self.updateAll({quiet: true});
self.updateTxHistory(); self.updateTxHistory();
}, 4000, { }, 4000, {
leading: false, leading: false,
@ -730,14 +732,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
$rootScope.$on('NewOutgoingTx', function() { $rootScope.$on('NewOutgoingTx', function() {
self.updateAll(null, true); self.updateAll({walletStatus: null, untilItChanges: true});
}); });
lodash.each(['NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved', lodash.each(['NewTxProposal', 'TxProposalFinallyRejected', 'TxProposalRemoved',
'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished' 'Local/NewTxProposal', 'Local/TxProposalAction', 'ScanFinished'
], function(eventName) { ], function(eventName) {
$rootScope.$on(eventName, function(event, untilItChanges) { $rootScope.$on(eventName, function(event, untilItChanges) {
self.updateAll(null, untilItChanges); self.updateAll({walletStatus: null, untilItChanges: untilItChanges});
$timeout(function() { $timeout(function() {
self.updateTxHistory(); self.updateTxHistory();
}, 3000); }, 3000);