prevent walletupdate to block the ui

This commit is contained in:
Matias Alejo Garcia 2016-06-14 08:39:34 -03:00
commit 3cc17f40b6
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
3 changed files with 32 additions and 17 deletions

View file

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

View file

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

View file

@ -7,10 +7,6 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
var ongoingProcess = {}; var ongoingProcess = {};
var processNames = { 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...'), 'scanning': gettextCatalog.getString('Scanning Wallet funds...'),
'recreating': gettextCatalog.getString('Recreating Wallet...'), 'recreating': gettextCatalog.getString('Recreating Wallet...'),
'generatingCSV': gettextCatalog.getString('Generating .csv file...'), 'generatingCSV': gettextCatalog.getString('Generating .csv file...'),