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