Merge pull request #742 from yemel/feature/better-off-alone

Review copay features for 1-of-1
This commit is contained in:
Gustavo Maximiliano Cortez 2014-06-25 11:34:51 -03:00
commit 8a8614fe5b
5 changed files with 87 additions and 13 deletions

View file

@ -47,13 +47,26 @@ angular.module('copayApp.controllers').controller('SendController',
var w = $rootScope.wallet;
w.createTx(address, amount, commentText, function() {
$scope.loading = false;
$rootScope.$flashMessage = {
message: 'The transaction proposal has been created',
type: 'success'
};
$rootScope.$digest();
w.createTx(address, amount, commentText, function(ntxid) {
if (w.totalCopayers > 1) {
$scope.loading = false;
$rootScope.$flashMessage = {
message: 'The transaction proposal has been created',
type: 'success'
};
$rootScope.$digest();
} else {
w.sendTx(ntxid, function(txid) {
$rootScope.$flashMessage = txid ? {
type: 'success',
message: 'Transaction broadcasted. txid: ' + txid
} : {
type: 'error',
message: 'There was an error sending the Transaction'
};
$scope.loading = false;
});
}
});
// reset fields

View file

@ -147,9 +147,10 @@ angular.module('copayApp.controllers').controller('TransactionsController',
if (w) {
var addresses = w.getAddressesStr();
if (addresses.length > 0) {
$scope.blockchain_txs = [];
$scope.blockchain_txs = $scope.wallet.txCache || [];
w.blockchain.getTransactions(addresses, function(txs) {
$timeout(function() {
$scope.blockchain_txs = [];
for (var i = 0; i < txs.length; i++) {
txs[i].vinSimple = _aggregateItems(txs[i].vin);
txs[i].voutSimple = _aggregateItems(txs[i].vout);
@ -157,6 +158,7 @@ angular.module('copayApp.controllers').controller('TransactionsController',
txs[i].fees = ((txs[i].fees * bitcore.util.COIN).toFixed(0)) * satToUnit;
$scope.blockchain_txs.push(txs[i]);
}
$scope.wallet.txCache = $scope.blockchain_txs;
$scope.loading = false;
}, 10);
});
@ -185,4 +187,10 @@ angular.module('copayApp.controllers').controller('TransactionsController',
$scope.loading = false;
};
// Autoload transactions on 1-of-1
if ($rootScope.wallet && $rootScope.wallet.totalCopayers == 1) {
$scope.lastShowed = true;
$scope.getTransactions();
}
});