updateTxs from SendController is async to avoid delay on mobile. Txps are below.
This commit is contained in:
parent
beef856961
commit
dfaf40b550
2 changed files with 49 additions and 25 deletions
|
|
@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
preconditions.checkState(w);
|
preconditions.checkState(w);
|
||||||
preconditions.checkState(w.settings.unitToSatoshi);
|
preconditions.checkState(w.settings.unitToSatoshi);
|
||||||
|
|
||||||
$rootScope.title = 'Send';
|
$rootScope.title = w.isShared() ? 'Create Transaction Proposal' : 'Send';
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.error = $scope.success = null;
|
$scope.error = $scope.success = null;
|
||||||
var satToUnit = 1 / w.settings.unitToSatoshi;
|
var satToUnit = 1 / w.settings.unitToSatoshi;
|
||||||
|
|
@ -42,9 +42,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.updateTxs = _.throttle(function() {
|
$scope.updateTxs = _.throttle(function(cb) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (!w) return;
|
if (!w || !cb) return;
|
||||||
|
|
||||||
var res = w.getPendingTxProposals();
|
var res = w.getPendingTxProposals();
|
||||||
_.each(res.txs, function(tx) {
|
_.each(res.txs, function(tx) {
|
||||||
|
|
@ -61,7 +61,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$scope.txps = res.txs;
|
return cb(res.txs);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,14 +120,24 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$rootScope.pendingTxCount = 0;
|
$rootScope.pendingTxCount = 0;
|
||||||
$scope.updateTxs();
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
w.on('txProposalEvent', $scope.updateTxs);
|
w.on('txProposalEvent', function() {
|
||||||
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on("$destroy", function(){
|
$scope.$on("$destroy", function(){
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
w.removeListener('txProposalEvent', $scope.updateTxs );
|
w.removeListener('txProposalEvent', function() {
|
||||||
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.showAddressBook = function() {
|
$scope.showAddressBook = function() {
|
||||||
|
|
@ -155,7 +165,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
$scope.error = message;
|
$scope.error = message;
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.updateTxs();
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submitForm = function(form) {
|
$scope.submitForm = function(form) {
|
||||||
|
|
@ -201,7 +213,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
if (err) return $scope._showError(err);
|
if (err) return $scope._showError(err);
|
||||||
|
|
||||||
$scope.notifyStatus(status);
|
$scope.notifyStatus(status);
|
||||||
$scope.updateTxs();
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -422,7 +436,11 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
w.issueTx(ntxid, function(err, txid, status) {
|
w.issueTx(ntxid, function(err, txid, status) {
|
||||||
$scope.notifyStatus(status);
|
$scope.notifyStatus(status);
|
||||||
if (cb) return cb();
|
if (cb) return cb();
|
||||||
else $scope.updateTxs();
|
else {
|
||||||
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -432,14 +450,18 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
w.signAndSend(ntxid, function(err, id, status) {
|
w.signAndSend(ntxid, function(err, id, status) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.notifyStatus(status);
|
$scope.notifyStatus(status);
|
||||||
$scope.updateTxs();
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.reject = function(ntxid) {
|
$scope.reject = function(ntxid) {
|
||||||
w.reject(ntxid);
|
w.reject(ntxid);
|
||||||
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
|
||||||
$scope.updateTxs();
|
$scope.updateTxs(function(txps) {
|
||||||
|
$scope.txps = txps;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.clearMerchant = function(callback) {
|
$scope.clearMerchant = function(callback) {
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,13 @@
|
||||||
<div class="send" ng-controller="SendController" ng-init="init()">
|
<div class="send" ng-controller="SendController" ng-init="init()">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-12 medium-12 small-12 columns">
|
<div class="large-12 medium-12 small-12 columns">
|
||||||
<div ng-show="txps.length != 0" class="line-dashed-h m20b"></div>
|
|
||||||
<h1 class="hide-for-large-up">{{$root.title}}</h1>
|
<h1 class="hide-for-large-up">{{$root.title}}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" ng-show="txps.length != 0">
|
|
||||||
<div class="large-12 columns">
|
|
||||||
<h2 translate>Pending Transactions Proposals</h2>
|
|
||||||
<div class="panel last-transactions pr"
|
|
||||||
ng-repeat="tx in txps | paged"
|
|
||||||
ng-include="'views/includes/transaction.html'"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<h2 ng-show="txps.length != 0" translate>Create Transaction Proposal</h2>
|
|
||||||
<form name="sendForm" ng-submit="submitForm(sendForm)" novalidate>
|
<form name="sendForm" ng-submit="submitForm(sendForm)" novalidate>
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<p class="text-warning size-16"
|
<p class="text-warning size-16"
|
||||||
|
|
@ -167,7 +157,7 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<textarea id="comment" ng-disabled="loading"
|
<textarea id="comment" ng-disabled="loading"
|
||||||
name="comment" placeholder="{{(wallet.isShared() ? 'Leave a private message to your copayers' : 'Add a private comment to identify the transaction') |translate}}" ng-model="commentText" ng-maxlength="100"></textarea>
|
name="comment" placeholder="{{($root.wallet.isShared() ? 'Leave a private message to your copayers' : 'Add a private comment to identify the transaction')}}" ng-model="commentText" ng-maxlength="100"></textarea>
|
||||||
<i class="icon-compose"></i>
|
<i class="icon-compose"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -197,6 +187,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-show="$root.wallet.isShared() && txps.length != 0">
|
||||||
|
<div class="line-dashed-h m20b"></div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-12 columns">
|
||||||
|
<h2 translate>Pending Transactions Proposals</h2>
|
||||||
|
<div class="panel last-transactions pr"
|
||||||
|
ng-repeat="tx in txps | paged"
|
||||||
|
ng-include="'views/includes/transaction.html'"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="line-dashed-h m20b"></div>
|
<div class="line-dashed-h m20b"></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue