show error message after click

This commit is contained in:
Javier 2016-03-14 12:21:55 -03:00
commit 7540ee0a65
4 changed files with 45 additions and 33 deletions

View file

@ -58,13 +58,13 @@
<div ng-if="!gettingAddress"> <div ng-if="!gettingAddress">
<ul class="no-bullet"> <ul class="no-bullet">
<li class="line-b" ng-repeat="w in wallets"> <li class="line-b" ng-repeat="w in wallets">
<a ng-click="w.needsBackup || selectWallet(w.id, w.name)" class="db oh"> <a ng-click="selectWallet(w.id, w.name)" class="db oh">
<div class="avatar-wallet" <div class="avatar-wallet"
ng-style="{'background-color':w.color}"> ng-style="{'background-color':w.color}">
<i class="icon-wallet size-21"></i> <i class="icon-wallet size-21"></i>
</div> </div>
<div class="ellipsis name-wallet text-bold">{{w.name || w.id}} <div class="ellipsis name-wallet text-bold">{{w.name || w.id}}
<span class="has-error right text-light size-12" ng-show="w.needsBackup"> <span class="has-error right text-light size-12" ng-show="needsBackup[w.id]">
<i class="icon-close-circle size-14"></i> <i class="icon-close-circle size-14"></i>
<span class="vm" translate>Needs backup</span> <span class="vm" translate>Needs backup</span>
</span> </span>

View file

@ -128,7 +128,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted(); self.isPrivKeyEncrypted = fc.isPrivKeyEncrypted();
self.externalSource = fc.getPrivKeyExternalSourceName(); self.externalSource = fc.getPrivKeyExternalSourceName();
self.account = fc.credentials.account; self.account = fc.credentials.account;
self.needsBackup = profileService.isBackupNeeded(self.walletId);
if (self.externalSource == 'trezor') if (self.externalSource == 'trezor')
self.account++; self.account++;
@ -153,16 +152,19 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} }
} }
self.openWallet(function() { profileService.isBackupNeeded(self.walletId, function(needsBackup) {
if (!self.isComplete) { self.needsBackup = needsBackup;
$log.debug('Wallet not complete after update... redirecting'); self.openWallet(function() {
go.path('copayers'); if (!self.isComplete) {
} else { $log.debug('Wallet not complete after update... redirecting');
if ($state.is('copayers')) { go.path('copayers');
$log.debug('Wallet Complete after update... redirect to home'); } else {
go.walletHome(); if ($state.is('copayers')) {
$log.debug('Wallet Complete after update... redirect to home');
go.walletHome();
}
} }
} });
}); });
}); });
}; };

View file

@ -246,21 +246,28 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}; };
$scope.selectWallet = function(walletId, walletName) { $scope.selectWallet = function(walletId, walletName) {
$scope.gettingAddress = true; profileService.isBackupNeeded(walletId, function(needsBackup) {
$scope.selectedWalletName = walletName; $scope.needsBackup = {};
$timeout(function() { $scope.needsBackup[walletId] = needsBackup;
$scope.$apply(); if (needsBackup) return;
});
addressService.getAddress(walletId, false, function(err, addr) {
$scope.gettingAddress = false;
if (err) { $scope.gettingAddress = true;
self.error = err; $scope.selectedWalletName = walletName;
$modalInstance.dismiss('cancel'); $timeout(function() {
return; $scope.$apply();
} });
$modalInstance.close(addr); addressService.getAddress(walletId, false, function(err, addr) {
$scope.gettingAddress = false;
if (err) {
self.error = err;
$modalInstance.dismiss('cancel');
return;
}
$modalInstance.close(addr);
});
}); });
}; };
}; };

View file

@ -668,12 +668,16 @@ angular.module('copayApp.services')
}); });
}; };
root.isBackupNeeded = function(walletId) { root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId); var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return false; if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return false; if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return false; if (c.credentials.network == 'testnet') return cb(false);
return true;
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
}; };
root.getWallets = function(network) { root.getWallets = function(network) {
@ -690,8 +694,7 @@ angular.module('copayApp.services')
id: c.walletId, id: c.walletId,
network: c.network, network: c.network,
color: config.colorFor[c.walletId] || '#4A90E2', color: config.colorFor[c.walletId] || '#4A90E2',
copayerId: c.copayerId, copayerId: c.copayerId
needsBackup: root.isBackupNeeded(c.walletId)
}; };
}); });
if (network) { if (network) {