mirror of https://github.com/BTCPrivate/copay.git
handler for untilItchanges to txps
This commit is contained in:
parent
4a1ab0eb16
commit
e9d90d16fa
|
@ -158,11 +158,30 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
var _walletStatusHash = function(walletStatus) {
|
||||
var st = {};
|
||||
|
||||
self.updateAll = function(walletStatus, untilItChanges, initBalance, tries) {
|
||||
if (walletStatus) {
|
||||
st.bal = walletStatus.balance.totalAmount;
|
||||
st.txs = walletStatus.pendingTxps;
|
||||
} else {
|
||||
st.bal = self.totalBalanceSat;
|
||||
st.txs = self.txps;
|
||||
}
|
||||
|
||||
var hash = st.bal + ':';
|
||||
if (st.txs) {
|
||||
hash += lodash.map(st.txs, function(t) {
|
||||
return t.id + ':' + (t.actions ? t.actions.length : 0);
|
||||
}).join(':');
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
||||
self.updateAll = function(walletStatus, untilItChanges, initStatusHash, tries) {
|
||||
tries = tries || 0;
|
||||
if (untilItChanges && lodash.isUndefined(initBalance)) {
|
||||
initBalance = self.totalBalanceSat;
|
||||
if (untilItChanges && lodash.isUndefined(initStatusHash)) {
|
||||
initStatusHash = _walletStatusHash();
|
||||
}
|
||||
var get = function(cb) {
|
||||
if (walletStatus)
|
||||
|
@ -187,9 +206,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.setOngoingProcess('updatingStatus', true);
|
||||
$log.debug('Updating Status:', fc, tries);
|
||||
get(function(err, walletStatus) {
|
||||
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 7) {
|
||||
if (!err && untilItChanges && initStatusHash == _walletStatusHash(walletStatus) && tries < 7) {
|
||||
return $timeout(function() {
|
||||
return self.updateAll(null, true, initBalance, ++tries);
|
||||
return self.updateAll(null, true, initStatusHash, ++tries);
|
||||
}, 1400 * tries);
|
||||
}
|
||||
self.setOngoingProcess('updatingStatus', false);
|
||||
|
|
|
@ -136,6 +136,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.loading = null;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.refreshUntilItChanges = false;
|
||||
|
||||
$scope.getShortNetworkName = function() {
|
||||
return fc.credentials.networkName.substring(0, 4);
|
||||
|
@ -223,7 +224,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
if (memo)
|
||||
$log.info(memo);
|
||||
|
||||
txpsb.refreshUntilItChanges = true;
|
||||
$scope.refreshUntilItChanges = true;
|
||||
$modalInstance.close(txpsb);
|
||||
}
|
||||
});
|
||||
|
@ -249,6 +250,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.error = err.message || gettext('Could not reject payment. Check you connection and try again');
|
||||
$scope.$digest();
|
||||
} else {
|
||||
$scope.refreshUntilItChanges = true;
|
||||
$modalInstance.close(txpr);
|
||||
}
|
||||
});
|
||||
|
@ -272,6 +274,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.$digest();
|
||||
return;
|
||||
}
|
||||
$scope.refreshUntilItChanges = true;
|
||||
$modalInstance.close();
|
||||
});
|
||||
}, 100);
|
||||
|
@ -294,7 +297,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
if (memo)
|
||||
$log.info(memo);
|
||||
|
||||
txpb.refreshUntilItChanges = true;
|
||||
$scope.refreshUntilItChanges = true;
|
||||
$modalInstance.close(txpb);
|
||||
}
|
||||
});
|
||||
|
@ -323,15 +326,14 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
});
|
||||
|
||||
modalInstance.result.then(function(txp) {
|
||||
var refreshUntilItChanges = txp ? txp.refreshUntilItChanges : null;
|
||||
self.setOngoingProcess();
|
||||
if (txp) {
|
||||
txStatus.notify(txp, function() {
|
||||
$scope.$emit('Local/TxProposalAction', refreshUntilItChanges);
|
||||
$scope.$emit('Local/TxProposalAction', $scope.refreshUntilItChanges);
|
||||
});
|
||||
} else {
|
||||
$timeout(function() {
|
||||
$scope.$emit('Local/TxProposalAction');
|
||||
$scope.$emit('Local/TxProposalAction', $scope.refreshUntilItChanges);
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue