Merge pull request #4375 from matiu/feat/walletupdate

prevent walletupdate to block the ui
This commit is contained in:
Gustavo Maximiliano Cortez 2016-06-14 09:30:24 -03:00 committed by GitHub
commit 41f76292fe
3 changed files with 32 additions and 17 deletions

View File

@ -16,6 +16,20 @@
</div>
</div>
<div class="onGoingProcess" ng-show="index.updating">
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
<div class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<span translate>Updating Wallet...</span>
</div>
</div>
<div class="oh" ng-show="!index.noFocusedWallet">
<!--
@ -34,7 +48,7 @@
</ion-refresher>
<div class="oh pr">
<div ng-style="{'background-color':index.backgroundColor}" class="amount">
<div ng-if="!index.notAuthorized">
<div ng-if="!index.notAuthorized && !index.updating">
<div class="m15t" ng-show="index.updateError" ng-click='index.updateAll({triggerTxUpdate: true})'>
<span class="size-12 db m10b">{{index.updateError|translate}}</span>
<button class="outline white tiny round" translate>Tap to retry</button>
@ -60,6 +74,11 @@
</div>
</div>
</div>
<div ng-if="index.updating">
<div class="size-36">
<strong>...</strong>
</div>
</div>
</div> <!-- amount -->
<div class="wallet-info">
@ -79,7 +98,7 @@
</span>
</div>
</div>
<div class="oh pr m20t" ng-show="index.notAuthorized">
<div class="oh pr m20t" ng-show="index.notAuthorized && !index.updating">
<div class="text-center text-warning">
<i class="fi-alert"></i>
<span translate>
@ -319,7 +338,7 @@
-->
<div id="send" class="send tab-view">
<div class="pr p25b">
<h4 class="title m0">
<h4 class="title m0" ng-show="!index.updating">
<available-balance ng-show="!index.shouldHideBalance"></available-balance>
<span
ng-show="home.lockedCurrentFeePerKb || home.lockAmount"
@ -345,7 +364,7 @@
</div>
<div class="row m20t">
<div class="large-12 large-centered columns">
<form name="sendForm" novalidate>
<form name="sendForm" novalidate>
<div ng-hide="home._paypro || home.hideAddress">
<div class="row collapse">
@ -441,7 +460,7 @@
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.paymentExpired"
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.paymentExpired || index.updating"
ng-style="{'background-color':index.backgroundColor}" ng-click="home.submitForm()" translate>
Send
</button>

View File

@ -117,6 +117,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.hasProfile = true;
self.isSingleAddress = false;
self.noFocusedWallet = false;
self.updating = false;
// Credentials Shortcuts
self.m = fc.credentials.m;
@ -302,7 +303,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$timeout(function() {
if (!opts.quiet)
ongoingProcess.set('updatingStatus', true);
self.updating = true;
$log.debug('Updating Status:', fc.credentials.walletName, tries);
get(function(err, walletStatus) {
@ -322,8 +323,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
if (walletId != profileService.focusedClient.credentials.walletId)
return;
ongoingProcess.set('updatingStatus', false);
self.updating = false;
if (err) {
self.handleError(err);
@ -387,10 +387,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updatePendingTxps = function() {
var fc = profileService.focusedClient;
$timeout(function() {
ongoingProcess.set('updatingPendingTxps', true);
self.updating = true;
$log.debug('Updating PendingTxps');
fc.getTxProposals({}, function(err, txps) {
ongoingProcess.set('updatingPendingTxps', false);
self.updating = false;
if (err) {
self.handleError(err);
} else {
@ -426,10 +426,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
var fc = profileService.focusedClient;
$timeout(function() {
$rootScope.$apply();
ongoingProcess.set('openingWallet', true);
self.updating = true;
self.updateError = false;
fc.openWallet(function(err, walletStatus) {
ongoingProcess.set('openingWallet', false);
self.updating = false;
if (err) {
self.updateError = true;
self.handleError(err);
@ -1628,7 +1628,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy'], function(eventName) {
$rootScope.$on(eventName, function() {
var f = function() {
if (self.updatingStatus) {
if (self.updating) {
return $timeout(f, 200);
};
self.updatePendingTxps();

View File

@ -7,10 +7,6 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
var ongoingProcess = {};
var processNames = {
'openingWallet': gettextCatalog.getString('Updating Wallet...'),
'updatingStatus': gettextCatalog.getString('Updating Wallet...'),
'updatingBalance': gettextCatalog.getString('Updating Wallet...'),
'updatingPendingTxps': gettextCatalog.getString('Updating Wallet...'),
'scanning': gettextCatalog.getString('Scanning Wallet funds...'),
'recreating': gettextCatalog.getString('Recreating Wallet...'),
'generatingCSV': gettextCatalog.getString('Generating .csv file...'),